: Glenn Jackman wrote:
: >
: >>i wan't to write a regular expression who match imesh but no match
: >>tIMESHeet. How can i do that ?
: >
: > A simple way is to just use 2 expressions. There's surely a clever RE,
: > but it may not improve readability.
: >
: > if ($str =~ /imesh/i and $str !~ /timesheet/i) {
: > # do something
: > }
: >
: sorry, but i want one expression
Why?
Do you have a subroutine that only accepts a regex argument?
Modifying that subroutine may be a better idea than trying to conform
to its expectations.
Are you planning to use a Perl regex in something besides a Perl
program? You might get something you can't use.
Anyway,
m/(?
?<=(t))|(?<!t))imesh(?(1)(?!eet))/
^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^
Man, that's f'ed up, but it's the best I could come up with to make
the conditional pattern at the end work, without spending too much
time on it.
Two match operations is definitely the less nauseating approach.