|
-
Apr 25th, 2010, 04:59 AM
#1
Thread Starter
Lively Member
Searching the string
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?
Save trees, avoid plastics, say no to zoo, go veg, recycle as much, live holistic
-
Apr 25th, 2010, 10:51 AM
#2
Re: Searching the string
using the regular expression below with preg_match() should work fine:
Code:
@(<(a|div|/)|http://|htm)@i
for example:
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"; }
if you would like an explanation of the regular expression, please don't hesitate to ask.
-
Apr 26th, 2010, 10:49 AM
#3
Thread Starter
Lively Member
Re: Searching the string
Thank you "David", I will take your offer. I have read a few tutorials but never really able to understand regular expressions.
Save trees, avoid plastics, say no to zoo, go veg, recycle as much, live holistic
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|