Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: In search of a better way to trim string

by kiat (Vicar)
on Jul 19, 2004 at 11:30 UTC ( [id://375522]=note: print w/replies, xml ) Need Help??


in reply to Re: In search of a better way to trim string
in thread In search of a better way to trim string

Maybe just add a line to return the string when its length is shorter than the desired length. Otherwise, with a string like "this is a very long sentence", you get "this is a very long ..." instead of "this is a very long sentence".

Thanks and cheers :)

  • Comment on Re^2: In search of a better way to trim string

Replies are listed 'Best First'.
Re^3: In search of a better way to trim string
by Jasper (Chaplain) on Jul 19, 2004 at 12:20 UTC
    Yes, sorry about that. I'm sure there's a one character change that makes the regex not match when it's shorter than $length, but a) I can't see it immediately, b) that's just stupid golfing.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-19 14:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found