Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Difference Between The 2 Statements

Reply
Thread Tools

Difference Between The 2 Statements

 
 
RN1
Guest
Posts: n/a
 
      04-13-2008
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
 
Reply With Quote
 
 
 
 
Jesse Houwing
Guest
Posts: n/a
 
      04-13-2008
Hello RN1,

> 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,



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


 
Reply With Quote
 
 
 
 
Peter Morris
Guest
Posts: n/a
 
      04-13-2008
q followed by anything as long as it is not q == match
q followed by q == no match



 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      04-14-2008
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:(E-Mail Removed)...
>q followed by anything as long as it is not q == match
> q followed by q == no match



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between following statements deepak C Programming 25 03-11-2013 02:43 AM
component statements within architecture statements Neil Zanella VHDL 8 10-20-2006 09:05 AM
What's the difference between these 2 statements? ATSkyWalker Python 11 04-20-2005 08:49 PM
Difference between bin and obj directories and difference between project references and dll references jakk ASP .Net 4 03-22-2005 09:23 PM
if statements with or w/o else statements Harry George Python 6 02-23-2004 06:48 PM



Advertisments