Checking for character absence with regular expressions

From: Date: Fri, 16 Jul 2004 12:21:05 +0000
Subject: Checking for character absence with regular expressions
Groups: php.general 
Request: Send a blank email to php-general+get-190702@lists.php.net to get a copy of this message
Hi List 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, I have used PHP's POSIX functions, but if someone has a solution for PCRE, I will use that as well. 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. 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). I have RTFM, RTFA, STFW and perhaps I am not phraseing my search terms correctly, as I am having no luck. Can anyone suggest a solution? ==================== Rory McKinley Nebula Solutions +27 21 555 3227 - office +27 21 551 0676 - fax +27 82 857 2391 - mobile www.nebula.co.za ==================== This e-mail is intended only for the person to whom it is addressed and may contain confidential information which may be legally privileged. Nebula Solutions accepts no liability for any loss, expense or damage arising from this e-mail and/or any attachments.

« previous php.general (#190702) next »