Here is one way:
/(n=[^']*)/;
which says find a n= and then everything up to the next '
You probably want to wrap in if statement so if not a hit, then can
do something.
Wags
-----Original Message-----
From: Dan Finch [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 17, 2002 09:09
To: [EMAIL PROTECTED]
Subject: Pattern Matching
I'm working on a script that I need to use some pattern matching in. I've
got a couple books that I have been reading about it and thought I knew how
to seach for what I'm after but its just not working.
Here is a test script I've been playing with to get this working. I want to
be able to parse out of the string any one of the 'letter=values'. The way
I'm trying to get this to work is by searching for the Letter of the
parameter I'm searching for follow by the =. Then I add a .* which matches
anything. Then I want to match to end with a '
But no matter what I've tried I will never find the ' It find the beginning
of my search then go to the end of the string. I've played with escaping
the ' but that didnt seem to work either.
What I end up having to do to get it to work is end the seach with the
Letter= of the next variable in the string and then clean it up but I really
don't want to have to do it that way as its not very flexable and relies on
the string being in a certain order and I don't want to count on that.
If anyone has an idea about what I'm doing wrong I would be most grateful.
#!/usr/bin/perl
$test = "'A=test' 'P=lkjae' 'p=12' 'H=goober@localhost' 'n=crfrinch'
't=3453462'";
$_ = $test;
/(n=.*')/;
$username = $1;
print "$1\n";
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]