kitwei
asked on
regex question
Hi, I'm having trouble with this regex. Here is what I do:
$text = 'abc="123" def="456"';
$text =~ s/abc="(.*)"/;
print $1;
the value of $1 I get is
123" def="456
but I only want 123. I actually don't know the string within the quote, it could be anything. The thing I know is abc="<string>" and def="<string>"
How do I specify such that the second quote of "(.*)" is the next quote, instead of the last quote of the wholte string?
Any idea? Thanks much!
$text = 'abc="123" def="456"';
$text =~ s/abc="(.*)"/;
print $1;
the value of $1 I get is
123" def="456
but I only want 123. I actually don't know the string within the quote, it could be anything. The thing I know is abc="<string>" and def="<string>"
How do I specify such that the second quote of "(.*)" is the next quote, instead of the last quote of the wholte string?
Any idea? Thanks much!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellent! Thank you!
or
$text =~ /abc="([^"]*)/";