On 9/27/06, Owen <[EMAIL PROTECTED]> wrote:
On Wed, 27 Sep 2006 13:11:17 -0600
"Gerald Wheeler" <[EMAIL PROTECTED]> wrote:
> I am looking for: ab1 in line1
> and looking for: ab2 in line 2
>
> actually ab1 and ab2 immediately follow the last "/" (there are
> numerous "/" on the line (w/o quotes))
>
> These are not working. can some explain what these say and what they
> should say (syntax) to return the results I'm looking for: if ab1/ab2
> are in the line, return true.
>
> /^[^\#]*ab1/,@lines
>
> /^[^\#]*ab2/,@lines
Is there more to this code somewhere? This says "match $_ against a
pattern, ignore the result and return @lines." I doubt that's what you
want. If you have warnings on, it should give you warnings like
"useless use of [something or other]" and "use of uninitialized value
in pattern match (m//) at..."
Did you intend a grep or something similar there? Something like
my @hits = grep /^[^\#]*ab1/, @lines
might return a useful result.
As for the patterns themselves, '^' means "start looking at the
beginning of the string." '[^\#]*' means "look for zero or more
characters in the class of all characters that aren't '\' or '#'. And
'ab1' means exactly that.
Presumeably you want a match against '/ab1'
In which case you might just get by with /\/ab1/
But you may need to provide a few more specifications and example data
But that will match any ab1, not just the one after the last '/'
If '/ab1' will always be the end of the string, or at least the end of
a word, you could go for:
/\ab1$/
or
/\ab1\s/
That makes assumptions that may not be valid, though. we'd need to see data.
Failing test data--or given unpredictable data--I'd go for something like:
m{.*/ab1} && $' !~ m{/}
or
m{/ab1[^/]*$}
Although I'm sure someone will have a more efficient, or at least more
elegant, approach.
HTH,
-- jay
--------------------------------------------------
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential
daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org
values of β will give rise to dom!