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:
Post deleted by dendro

 



dendro
New User

Apr 22, 2011, 2:19 AM

Post #1 of 3 (2752 views)
Post deleted by dendro

 


miller
User

Apr 22, 2011, 9:56 AM

Post #2 of 3 (2725 views)
Re: [dendro] Need help with small but tricky job [In reply to] Can't Post

How are your single quoted strings escaped there? If it's a bash script, then there is no way to escape them. Or does a backslash work? Or doubling?

The simpliest form of this type of regex would be the following. Basically separate the the parsing of the single quoted values from the escaping of the space characters:


Code
my $str = q{command arg0='na me' arg1='oth r'}; 

$str =~ s{('.*?')}{my $q = $1; $q =~ s/(\s)/\\$1/g; $q}eg;

print $str;


If you give me more information on how your single quoted strings are escaped, I can show you a more complete regex. Examples of such escaping would be helpful.

- Miller


(This post was edited by miller on Apr 22, 2011, 9:58 AM)


dendro
New User

Apr 26, 2011, 1:47 AM

Post #3 of 3 (2689 views)
Re: [miller] Need help with small but tricky job [In reply to] Can't Post

OK. That is fine solution but when I get this in perl pie it add \ before every space.

perl -p -i -e '~ s{('.*?')}{my $q = $1; $q =~ s/(\s)/\\$1/g; $q}eg' $1

 
 


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

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