Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: How to substitute all tabs only in a specific field

by kcott (Archbishop)
on May 26, 2020 at 09:51 UTC ( [id://11117271]=note: print w/replies, xml ) Need Help??


in reply to Re: How to substitute all tabs only in a specific field
in thread How to substitute all tabs only in a specific field

"The one from Kcott "almost" worked. The double-quote fields are correct, the ones before the quotes are missing :)."

Yes, I forgot to capture the first part of the strings. Fixing that, and then making changes for your altered input and updated spec:

$ perl -pE 's/^([^"]+")([^"]+)/$1 . $2 =~ y{\t}{,}r/e' a b "x1 x2" a b "x1,x2" c d "x2" c d "x2" e f "x3 x4 x5" e f "x3,x4,x5"
"I was not able to add "tabs" in the example ..."

Surely you must mean something else. I pressed the key labelled "TAB" on my keyboard to add them to my input. Admittedly, it may not be easy to see the difference between a tab and a space, but the output gives it away:

$ perl -pE 's/^([^"]+")([^"]+)/$1 . $2 =~ y{\t}{,}r/e' a b "x1 x2" a b "x1 x2"

— Ken

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-25 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found