Stripping trailing spaces from a string
Jim Ault
JimAultWins at yahoo.com
Sun Mar 5 01:51:08 EST 2006
On 3/4/06 8:00 PM, "Jim Witte" <jswitte at bloomington.in.us> wrote:
> How can I use a RegEx to strip trailing white-space? I tried:
>
> get matchText(theExpr, "(.*)\s*", theExpr)
>
> where theExpr is "0025E95C mov r5, r0 "
> _______________________________________________
put "(.*[^\s])" into regEx --trims spaces from right
get matchText(strr,regEx,strr)
Basically says capture the whole string and come back until the character is
not a "word delimiter", not necessarily a space. If you only want spaces to
qualify then use
put "(.*[^\ ])" into regEx --trims spaces from right
(note the space char after the "\")
put "([^\s]+)" into RegEx --matches only the first word
Basically says capture the characters as long as it is not a "word
delimiter".
Ken has MUCH better experience and even gives time trial results :-)
Jim Ault
Las Vegas
More information about the use-livecode
mailing list