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>


|