Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Programmer > Re: Help with R...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 16 Topic 986 of 1040
Post > Topic >>

Re: Help with RegEx?

by dempson@[EMAIL PROTECTED] (David Empson) Jan 6, 2008 at 03:06 PM

SparkyGuy <sparkyguy@[EMAIL PROTECTED]
> wrote:

> >      [Ii].*[Nn].*[Tt].*[Uu].*[Oo].*[Nn]
> 
> It turns out that this does work to find terms with all these letters in
this
> order even if there are other characters interspersed between them. Such
as:
> 
>      intuition
>      in3t5u7ition
>      in tuitio9n
>      inBBtuCCon
> 
> Now I want to find terms that have all these characters in any order.
Such
> as:
> 
>      noiiitunt
>      tn8no9uitii
>      otAAnuiBiit
>      unt ioitni

To clarify: do you want at least one each of "I", "T", "U" and "O", and
at least two "N"s, in any order and mixed with any other characters (or
more of the same ones), ignoring case?

Tricky. You can't do that with a simple regular expression, or even a
Perl-compatible regular expression.

It would best done in parallel, testing the string against five
different regular expressions:

[Ii]
[Nn].*[Nn]
[Tt]
[Uu]
[Oo]

The string has to match all of these to pass.

If you really don't need two "N"s then you can simplify the second test
to be like the others. If you want a certain number of each letter, but
in any position, then use the same general syntax as the second line.

> I guess this has something to do with the ^ and $ parsing metasymbols
but I'm
> not knowledgeable enough on this topic to know how, exactly. 

Those just mean "start of string" and "end of string" respectively. For
example, if you want to only match a string which starts with "I" or "i"
then your regular expression is "^[Ii]".

-- 
David Empson
dempson@[EMAIL PROTECTED]

 




 16 Posts in Topic:
Help with RegEx?
SparkyGuy <sparkyguy@[  2008-01-05 23:07:58 
Re: Help with RegEx?
SparkyGuy <sparkyguy@[  2008-01-06 01:43:11 
Re: Help with RegEx?
dempson@[EMAIL PROTECTED]  2008-01-06 15:06:06 
Re: Help with RegEx?
SM Ryan <wyrmwif@[EMAI  2008-01-06 01:43:13 
Re: Help with RegEx?
Reinder Verlinde <rein  2008-01-06 15:25:24 
Re: Help with RegEx?
Paul Floyd <root@[EMAI  2008-01-06 15:25:32 
Re: Help with RegEx?
Ben Artin <macdev@[EMA  2008-01-08 21:27:23 
Re: Help with RegEx?
SparkyGuy <sparkyguy@[  2008-01-09 01:15:16 
Re: Help with RegEx?
dempson@[EMAIL PROTECTED]  2008-01-09 22:57:18 
Re: Help with RegEx?
SparkyGuy <sparkyguy@[  2008-01-09 18:28:01 
Re: Help with RegEx?
SparkyGuy <sparkyguy@[  2008-01-10 10:25:27 
Re: Help with RegEx?
John Whorfin <_@[EMAIL  2008-01-11 07:11:05 
Re: Help with RegEx?
SparkyGuy <sparkyguy@[  2008-01-10 20:58:02 
Re: Help with RegEx?
SparkyGuy <sparkyguy@[  2008-01-10 21:12:07 
Re: Help with RegEx?
dempson@[EMAIL PROTECTED]  2008-01-11 12:03:31 
Re: Help with RegEx?
Sherman Pendley <spamt  2008-01-10 18:20:34 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 10:05:13 CST 2008.