CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Regex help (regex to match text beetween set of parentheses)

 



quintus
Novice

Sep 7, 2011, 11:04 AM

Post #1 of 2 (2139 views)
Regex help (regex to match text beetween set of parentheses) Can't Post

Text format: (text1) text2 (text3)

1. I need regex to match text beetween first set of parentheses. Results: text1.
2. I need regex to match text beetween first set of parentheses and second set of parentheses. Results: text2.
3. I need regex to match text beetween second set of parentheses. Results: text3.

please give me a little help.
Thanks


(This post was edited by quintus on Sep 7, 2011, 1:46 PM)


daptal
Novice

Sep 7, 2011, 5:22 PM

Post #2 of 2 (2132 views)
Re: [quintus] Regex help (regex to match text beetween set of parentheses) [In reply to] Can't Post

 
if ($str1 =~ m/.*?\((.*?)\)(.*?)\((.*?)\)/){
print "$1\n$2\n$3\n";
}


just remember to use backslash for "(" when ever you want to match them and not store them

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives