Re: Checking for character absence with regular expressions
| From: | Jason Wong | Date: | Sat, 17 Jul 2004 02:12:57 +0000 |
| Subject: | Re: Checking for character absence with regular expressions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-190803@lists.php.net to get a copy of this message | ||
On Friday 16 July 2004 20:21, Rory McKinley wrote:
> I am currently trying to check for the absence of certain substrings
> within larger strings using
> regular expressions. I know that I could use on of the string functions,
> but in the interests of
> flexibility I must use a regexp match of some shape or variety. Up until
> now,
Could you explain why you need flexibility?
> An example of my problem:
>
> I need to check that the substring " R" (that's a space followed by an
> uppercase R) is not contained within my haystack.
A simple strpos() would suffice.
> E.g. Whatever pattern I match, if I match it against the following
> haystacks:
>
> "Blah Blah R 99.99" or "Blah Blah R99.99" it should return negative
> (i.e. the substring is contained within the haystack)
>
> while
>
> "Blah Blah 99.99CR" should return positive (i.e. the substring is not
> within the haystack).
TRUE/FALSE can easily be reversed using !.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
All of a sudden, I want to THROW OVER my promising ACTING CAREER, grow
a LONG BLACK BEARD and wear a BASEBALL HAT!! ... Although I don't know WHY!!
*/