tracker issue : CF-4199640

select a category, or use search below
(searches all categories and all time range)
Title:

Allow negative offsets for right() and left()

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Bradley Wood / Bradley Wood ()

Created: 09/11/2017

Components: Language

Versions: 2016

Failure Type: Others

Found In Build/Fixed In Build: / 2018,0,0,308598

Priority/Frequency: Normal /

Locale/System: / Platforms All

Vote Count: 1

Lucee Server has a very handy feature where the left() and right() functions allow you to pass a negative number which strips that many chars off of the Opposite end of the string.  It's basically turns it into an "all but this many chars" functionality as opposed to "only this many chars".  It's great for stripping something of known length off the start of a string like so:

myString='// { "foo" : "bar" }'
dump( myString.right( -2 ) )

https://trycf.com/gist/072280ef61590e17756d59f6262db30a/lucee5?theme=monokai

Attachments:

Comments: