I want to search a string for occurrence of several characters and word in one syntax; for example I want to look for characters "http://" "<a" "<div>" "</" "htm" and other tags in the string. All in one syntax. Can anyone help me?
Printable View
I want to search a string for occurrence of several characters and word in one syntax; for example I want to look for characters "http://" "<a" "<div>" "</" "htm" and other tags in the string. All in one syntax. Can anyone help me?
using the regular expression below with preg_match() should work fine:
for example:Code:@(<(a|div|/)|http://|htm)@i
if you would like an explanation of the regular expression, please don't hesitate to ask.PHP Code:$pattern = '@(<(a|div|/)|http://|htm)@i';
$str = "http://davidmiles.ca";
if(preg_match($pattern, $str)){
echo "the string was found";
}else{
echo "the string was not found";
}
Thank you "David", I will take your offer. I have read a few tutorials but never really able to understand regular expressions.