Detect HTML tags in a string

前端 未结 8 1463
渐次进展
渐次进展 2020-12-04 12:59

I need to detect whether a string contains HTML tags.

if(!preg_match(\'(?<=<)\\w+(?=[^<]*?>)\', $string)){ 
    return $string;
}
8条回答
  •  时光取名叫无心
    2020-12-04 13:36

    you need to 'delimit' the regex with some character or another. Try this:

    if(!preg_match('#(?<=<)\w+(?=[^<]*?>)#', $string)){ 
        return $string;
    }
    

提交回复
热议问题