Hey,
Here's a string
<b>Location:</b> Your computer<br />
I want my regex to catch everything EXCEPT "<b>Location:</b>"
I remember the ^ symbol is used to express NOT but i'm spending too much time in figuring out how to make it work.
Let me know if you have a quick answer for me,
Thanks,
Using NOT
Moderator: General Moderators
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Using NOT
Is that the whole string? Because you could just use substr()
http://php.net/substr
Code: Select all
$string = '<b>Location:</b> Your computer';
$location = substr($string, 17);-
fwycruiser118
- Forum Newbie
- Posts: 9
- Joined: Sat Oct 09, 2010 7:45 pm
- Location: Calif
Re: Using NOT
previous example is probably the best move but you might like this too
$subject = '<b>Location:</b>Your computer';
$pattern = "/^<b>Location:<\/b>(.*)/i";
preg_match_all($pattern, $subject, $matches);
print_r($matches);
echo $matches[1][0];
Re: Using NOT
I'd probably use http://php.net/strip_tags and then that way I don't have to put HTML tags in my regex, more clean. As shown the ^ (caret) is the "not" symbol in regex.
-
Goldwinterrain
- Forum Newbie
- Posts: 4
- Joined: Sun Mar 13, 2011 9:15 pm
Re: Using NOT
I remember the ^ symbol is used to express NOT but i'm spending too much time in figuring out how to make it work.
Let me know if you have a quick answer for me,
Let me know if you have a quick answer for me,