7stud -- wrote:
> 
> pattern = /url\((.*)\)/ #to match a parenthesis escape it with a '\'
> 

Actually, to be safe make the .* non-greedy:

pattern = /url\((.*?)\)/ #to match a parenthesis escape it with a '\'

Here's the difference:

str = "abcurl(good)bad)xyz"

pattern1 = /url\((.*)\)/ #to match a parenthesis escape it with a '\'
pattern2 = /url\((.*?)\)/ #to match a parenthesis escape it with a '\'


match1 = str[pattern1, 1]  #1 is the parenthesized sub pattern
puts match1

match2 = str[pattern2, 1]  #1 is the parenthesized sub pattern
puts match2

--output:--
good)bad
good
-- 
Posted via http://www.ruby-forum.com/.