Re: regular expression help
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 30 Mar 2007 12:16:49 -0700
On Mar 30, 2:51 pm, "bpatton" <bpat...@xxxxxx> wrote:
I'm trying to set up some limitation by using regular expressions
recorded in a hash table.
How do I do an 'and' in regular expressions?
$string = '-Dz=a =Dy=b -Dx=c -Dw=d -Dv=e -Du=f -Dt=g -Ds=h';
For an or I can
$search = '-Dx=(c|g|h)'; # this came from hash value
If ($string =~ /$search/) { # This works fine
...
}
Now how would I do an 'and' in any order
and
V
$search = '-Ds=(a|b|c)&&-Du=(f|g|h)'; # need both -Du and -Ds in any
order
If ($string =~ /$search/) {
...
}
It's probably very simple, just can't twist my mind around it :)
I can't separate the $search. It must always be a single string.
I would suggest fixing your algorithm to make more sense, so that it
doesn't hog tie you from using methods this messy, but until then...
if ($string =~ /Ds=[abc].*Du=[fgh]|Du=[fgh].*Ds=[abc]/) { ... }
Paul Lalli
.
- References:
- regular expression help
- From: bpatton
- regular expression help
- Prev by Date: FAQ 9.12 How do I put a password on my web pages?
- Next by Date: Re: regular expression help
- Previous by thread: regular expression help
- Next by thread: Re: regular expression help
- Index(es):
Relevant Pages
|
|