Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Regex Parsing Chars in a Line

by kel (Sexton)
on Nov 26, 2019 at 04:49 UTC ( [id://11109223]=note: print w/replies, xml ) Need Help??


in reply to Re: Regex Parsing Chars in a Line
in thread Regex Parsing Chars in a Line

By .+ I am targeting adjacent to anything, rather than spaces. And converting all but the first and last to underscores. I see a typo in my description that unnecessarily obfuscates....

Replies are listed 'Best First'.
Re^3: Regex Parsing Chars in a Line
by swl (Parson) on Nov 26, 2019 at 07:00 UTC

    Maybe you could avoid the regex approach and use split and join?

    # untested my @parts = split /-/, $input; my $first = shift @parts; my $last = pop @parts; my $reassembled; # then $reassembled = $first . '-' . join ('_', @parts) . '-' . $last; # or something like this $reassembled = join '_', @parts; $reassembled = join '-', ($first, $reassembled, $last);

    The above assumes no CSV type quoting issues with embedded separators, for which a proper CSV parser like Text::CSV is needed.

Re^3: Regex Parsing Chars in a Line
by AnomalousMonk (Archbishop) on Nov 26, 2019 at 08:38 UTC
    I see a typo in my description ...

    If you have not already done so (I don't see any Update), you might consider updating the errant node to clarify the mistake. Please see How do I change/delete my post?


    Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-24 04:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found