Remove one or multiple substring from the start of a given string -- default: remove whitespace characters
string:trim_start(STRING $string, $remove=[ " ", "\t", "\n", "\r", " ", "\v" ], INT $limit=0) : STRING
string:trim_start(" hi ")
#=> "hi "
string:trim_start("hi ")
#=> "hi "
string:trim_start("hi \n\n ")
#=> "hi \n\n "
string:trim_start("foo...",".")
#=> "foo..."
# trim multiple strings
string:trim_start(".foo...",['.','o'])
#=> "foo..."
# trim only maximum of 2 occurences from start of string
# note: by default, $limit = 0 means no-limit
string:trim_start(".foo...",['.'],2)
#=> "foo..."
string:trim_start("...foo...",'.', 2)
#=> ".foo..."
string:trim_start("...foo...",'...')
#=> "foo..."
# remove string
string:trim_start("foofoofoo bar ",'foo')
#=> " bar "
# remove maximum of 2 from start of string
string:trim_start("foobar foofoofoo",'foo',2)
#=> "bar foofoofoo"
string:trim_start("bar nice foofoobarfoo",['foo','bar'],2)
#=> " nice foofoobarfoo"
Copyright ©2013-2022 SunSed®. All rights reserved.