Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pattern Matching Question 1

Status
Not open for further replies.

JaySang

Technical User
Jun 26, 2003
43
CA
I'm reading in a file(code structure) line by line and I need to come up with a pattern match for a line:

indirect( field("VARIABLE") field("VARIBLE") etc etc etc )

I need to get the first field and the first variable only.

I have tried ^ or /o and i think I'm doing it wrong.

any suggestions ??

thanks

 
Given just the line of code you specified above, the following regex works fine. It might require some modification depending on what the rest of your file looks like.

Code:
$_ = 'indirect( field1("VARIABLE 1") field2("VARIABLE 2") etc etc etc )';
print "$1 - $2\n" if (m/^\s*indirect.*?(\w+).*?"(.+?)"/i);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top