Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: remove first and last character of string

by GrandFather (Saint)
on Oct 14, 2020 at 03:12 UTC ( [id://11122805]=note: print w/replies, xml ) Need Help??


in reply to remove first and last character of string

use strict; use warnings; my $str = q{"654321_1111"}; $str =~ s/^"|"$//g; print "'$str'\n";

Prints:

'654321_1111'

Note that the single quotes are added in the print to demonstrate that there are no "hidden" characters like spaces or line breaks included in the string.

Update: fix $str quoting issue pointed out by LanX.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Replies are listed 'Best First'.
Re^2: remove first and last character of string
by LanX (Saint) on Oct 14, 2020 at 09:51 UTC

      Indeed, or something like that.

      Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-28 21:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found