Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Looking for appropriate Regex

by Loops (Curate)
on Apr 07, 2013 at 09:22 UTC ( [id://1027339]=note: print w/replies, xml ) Need Help??


in reply to Looking for appropriate Regex

Hi,

There are a number of ways to craft a regular expression to do this. One is to use look-behind and look-ahead assertions. These make sure the characters surrounding the space character match, but will leave them alone and not include them in the text to be replaced:

$id =~ s/(?<=[a-z]) (?=[a-z])/,/;

However, the results of any regex are likely to be spotty. If instead you use a module like Text::CSV to parse your csv files, you should be able to receive your data clean with all commas intact

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1027339]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-03-28 14:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found