On Tue, Dec 16, 2014 at 4:29 PM, Kenneth Wolcott <kennethwolc...@gmail.com> wrote: > Well, I had to look at > http://perldoc.perl.org/perlrequick.html#Extracting-matches to find > out how much I had forgotten about extracting matches from a regex :-) > > This might be inefficient, but it seems to work: > > $shared_folder =~ m|\'([-A-Za-z/_]+)\'.+'([-A-Za-z/_]+)\'|; > print $2 . "\n"; > > > Would be good to come up with something better, hopefully...
In general, parsing with regex is difficult. It depends on how complex the data is. If no single-quotes can appear inside of those "values" then it should suffice to match on single quotes globally. Note that the m// operator returns a list of matches in list context. Instead of doing what you did above, you can try something like this: my @shared_folders = $example_string =~ /'([^']*)'/g; (Untested) See documentation on m// and /g. If you want something to actually do parsing I have heard that Text::Balanced <https://metacpan.org/search?q=Text::Balanced> is a good direction to go, but I can't say for sure whether it will solve this problem more precisely. Hope that helps. Regards, -- Brandon McCaig <bamcc...@gmail.com> <bamcc...@castopulence.org> Castopulence Software <https://www.castopulence.org/> Blog <http://www.bambams.ca/> perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }. q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.}; tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say' -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/