我需要在html字符串中搜索以下代码:
// Angular
import { Component, OnInit, ElementRef, ViewChild, ChangeDetectionStrategy, OnDestroy } from '@angular/core';
import dayGridPlugin from '@fullcalendar/daygrid';
// RXJS
import { debounceTime, distinctUntilChanged, tap, skip, take, delay ,map} from 'rxjs/operators';import { of, Subscription, Observable } from 'rxjs';
import { Store, select } from '@ngrx/store';
import { AppState } from '../../../../core/reducers';
import {TaskService} from '../../../../core/task'
@Component({
selector: 'kt-taskmanager-mytasks',
templateUrl: './mytasks.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class taskManagerComponent implements OnInit, OnDestroy {
calendarPlugins = [dayGridPlugin];
Task = "Hello World"
message : Observable<any>
tasks : Observable<any[]>
// Subscriptions
private subscriptions: Subscription[] = [];
constructor(
private store: Store<AppState>,
private http: TaskService,
) {}
ngOnInit() {
}
onClickMe() {
this.message = this.http.getAllTasks()
this.message.pipe(
tap( r => {this.tasks = r['results'],console.log(this.tasks)},
err => console.error(err)
))
.subscribe()
}
/**
* On Destroy
*/
ngOnDestroy() {
this.subscriptions.forEach(el => el.unsubscribe());
}
}
我如何用正则表达式找到它?
我尝试过:
<a href="http://example.com" target="_blank" title="Site name"><img src="http://site.loc/images/banners/we_on.png" width="88" height="31" alt="Site name"></a>
但是我得到了错误的未定义表达式。也许需要检查是否在html上我有一个链接以及该链接的$html = (string) $client->getBody(); //html content
$verified = preg_match('/ <a href="http://example.com" target="_blank"
title="Site name"><img src="http://site.loc/images/banners/we_on.png"
width="88" height="31" alt="Site name"></a>
/', $html) ? true : false;
?