[regex-coach] negative lookahead assertion bug? message 9 of 20)

recoach.z.pbowers at spamgourmet.com recoach.z.pbowers at spamgourmet.com
Thu May 22 04:17:26 UTC 2008


Break it down into elements.
 
[^a-z]{3}
 
This says MATCH if you find 3 characters in a row which are not lowercase
alphas.  None of A-D match in this case because all of them have at least
one lower-case alpha within those first 3 chars.
 
Add the negative lookahead:
 
(?![^a-z]{3})
 
Since NONE of them matched and we're doing a NEGATIVE lookahead then we end
up with a positive and so all of A-D match here.
 
-Peter


  _____  

From: Arian Hojat - armyofda12mnkeys at gmail.com
[mailto:+recoach+pbowers+7ef1bd310e.armyofda12mnkeys#gmail.com at spamgourmet.c
om] 
Sent: Wednesday, May 21, 2008 4:32 PM
To: General purpose mailing list for The Regex Coach
Subject: Re: [regex-coach] negative lookahead assertion bug?
message 9 of 20)


i think the last email was right about the pattern needing to be
([A-Z]-)(?![^a-z]{3})([a-z0-9A-Z]* ),
this one is like a double NOT, almost right?

Now I'm just curious with a pattern like this.... This pattern 
([A-Z]-)(?![^a-z]{3}) 
for text: A-xyz37 # B-ab6142 # C-Wxy66 # D-qrs93
matches
A-xyz37 # B-ab6142 # C-Wxy66 # D-qrs93

Its looking to make sure the next thing after Capital Letter dash isnt 3
lower case letters, then 'nots' it? 
aka it really looks ahead for 3 lowercase letters, and i thought would only
match A- and D-.

Thanks for the help btw, I wasnt sure if these were problems with program or
just me understanding regexes bad :) which is most likely the case.
Arian



2008/5/21 Laurent TAUPIAC <ltaupiac at lfdj.com>:


Negative lookup assertion should match to be validate.
If "Wxy" not match, the positive assertion failed.

If you want a Capital letter followed by a dash but not followed by 3 lower
case, you should match "not 3 lower case" 

([A-Z]-)(?![^a-z]{3})([a-z0-9]* )



Regards

Arian Hojat a écrit : 

Hello all,

had a question/possible bug report...
For the example on this webpage:
http://www.nuclearblender.com/leftovers/howto/regex/

this pattern is presented and i tried a positive lookup assertion which
worked, but this first negative one only matched the first pattern (global
option is on btw, so not sure why wont match).
Pattern: ([A-Z]-)(?![a-z]{3})([a-z0-9]* )
Text to lookup: A-xyz37 # B-ab6142 # C-Wxy66 # D-qrs93

Should match B-ab6142 and C-Wxy66 as they both (have a capital letter
followed by a dash), then (dont have 3 lower case letters), and (are
following by letters/numbers and a space)
only matches first one in the program.

Thanks, let me know if it should match only one if im wrong. Running latest
version on Windows XP.
Great Tool!
Arian



  _____  


_______________________________________________

regex-coach site list

regex-coach at common-lisp.net

http://common-lisp.net/mailman/listinfo/regex-coach



-- 











---------------------------------------------------------------------

Sorry, This disclamer is auto added by my company's FW

---------------------------------------------------------------------


















































Si vous n'etes pas destinataires de ce message, merci d'avertir l'expediteur
de l'erreur de distribution et de le detruire immediatement.
Ce message contient des informations confidentielles ou appartenant a La
Francaise des Jeux. Il est etabli a l'intention exclusive de ses
destinataires. Toute divulgation, utilisation, diffusion ou reproduction
(totale ou partielle) de ce message ou des informations qu'il contient, doit
etre prealablement autorisee.
Tout message electronique est susceptible d'alteration et son integrite ne
peut etre assuree. La Francaise des Jeux decline toute responsabilite au
titre de ce message s'il a ete modifie ou falsifie.

If you are not the intended recipient of this e-mail, please notify the
sender of the wrong delivery and delete it immediately from your system.
This e-mail contains confidential information or information belonging to La
Francaise des Jeux and is intended solely for the addressees. The
unauthorised disclosure, use, dissemination or copying (either whole or
partial) of this e-mail, or any information it contains, is prohibited.
E-mails are susceptible to alteration and their integrity cannot be
guaranteed. La Francaise des Jeux shall not be liable for this e-mail if
modified or falsified.
_______________________________________________
regex-coach site list
regex-coach at common-lisp.net
http://common-lisp.net/mailman/listinfo/regex-coach



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/regex-coach/attachments/20080522/5fab8a72/attachment.html>


More information about the regex-coach mailing list