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

Re^2: How to trim a line from leading and trailing blanks without using regex or non-standard modules

by likbez (Sexton)
on Aug 14, 2020 at 19:39 UTC ( [id://11120740]=note: print w/replies, xml ) Need Help??


in reply to Re: How to trim a line from leading and trailing blanks without using regex or non-standard modules
in thread How to trim a line from leading and trailing blanks without using regex or non-standard modules

So if you want the exact same semantic, it'll become far more complicated than this regex.

I agree. That's a good point. Thank you !

In other words it is not easy to design a good trim function without regex, but it is possible to design one that used regex, but treating the single quoted string as a special case

For example

trim(' ',$line)
vs
trim(/\s/.$line)
BTW this is impossible in Python which implements regex via library, unless you add a new lexical type to the Language (regex string instead of raw string that is used).
  • Comment on Re^2: How to trim a line from leading and trailing blanks without using regex or non-standard modules

Replies are listed 'Best First'.
Re^3: How to trim a line from leading and trailing blanks without using regex or non-standard modules
by LanX (Saint) on Aug 15, 2020 at 01:04 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (1)
As of 2024-04-25 01:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found