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 7 of 16 Topic 986 of 1040
Post > Topic >>

Re: Help with RegEx?

by Ben Artin <macdev@[EMAIL PROTECTED] > Jan 8, 2008 at 09:27 PM

In article <0001HW.C3A53B750065FE02B019F94F@[EMAIL PROTECTED]
>,
 SparkyGuy <sparkyguy@[EMAIL PROTECTED]
> wrote:

> I want to build a regular expression that will find certain characters
in a 
> field. For example:
> 
>      i,n,t,u,o,n 
> 
> all need to be present (at least once) for the RegEx interpreter to
label 
> this search True. The order is not im****tant, and case should be
ignored. 

REs are not the right tool for this job; while it is possible to build
such an 
RE, it's annoying. For example, this is a RE that would match every string

containing all of 'a', 'b', and 'c' in any order, case-insensitively:

([^aA][aA][^bB][bB][^cC][cC])|([^aA][aA][^cC][cC][^bB][bB])|([^bB][bB][^aA][aA][^
cC][cC])|([^bB][bB][^cC][cC][^aA][aA])|([^cC][cC][^aA][aA][^bB][bB])|([^cC][cC][^
bB][bB][^aA][aA])

If you are using a RE engine that allows RE options, then you can use /i
to 
indicate you want a case-insensitive match, and then you can simplify this
to

/([^a]a[^b]b[^c]c)|([^a]a[^c]c[^b]b)|([^b]b[^c]c[^a]a)|([^b]b[^a]a[^c]c)|([^c]c[^
a]a[^b]b)|([^c]c[^b]b[^a]a)/i

and you can further simplify this to

/([^a]a(([^b]b)|([^c]c)))|([^b]b(([^a]a)|([^c]c)))|([^c]c(([^a]a)|([^b]b)))/i

but as you can see, this is pretty painful and it gets exponentially more 
painful the more characters you want to match. 

Ben

-- 
If this message helped you, consider buying an item
from my wish list: <http://artins.org/ben/wishlist>

I changed my name: <http://periodic-kingdom.org/People/NameChange.php>
 




 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:09:10 CST 2008.