Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Difference Between The 2 Statements

0 views
Skip to first unread message

RN1

unread,
Apr 13, 2008, 7:39:07 AM4/13/08
to
Consider the following RegularExpression:

====================
q[^u]
====================

One of the RegEx tutorials I have come across says the following
w.r.t. the above RegEx:

====================
The above RegEx does not mean a 'q' not followed by a 'u'; rather it
means a 'q' followed by a character that is not a 'u'.
====================

Now what's the difference between the 2 statements that I have cited
above?

Thanks,

Ron

Jesse Houwing

unread,
Apr 13, 2008, 8:49:34 AM4/13/08
to
Hello RN1,


condider this input:

q

this could be read as a q not followed by a u.

condider

qd

this could be read as a q not followed by a u.

in regex this would be written as:

q(?!u)

The other regex however will never match the first option, because q[^u]
alsways needs to match at least 2 characters, a q and a different character
than u.


--
Jesse Houwing
jesse.houwing at sogeti.nl


Peter Morris

unread,
Apr 13, 2008, 1:17:52 PM4/13/08
to
q followed by anything as long as it is not q == match
q followed by q == no match

Juan T. Llibre

unread,
Apr 14, 2008, 7:33:35 AM4/14/08
to
Also, q followed by nothing = no match

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Peter Morris" <mrpmorris at gmail dot com> wrote in message news:uR7P20gn...@TK2MSFTNGP04.phx.gbl...

0 new messages