Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove any string from a variable
#2
Use replacerx or findrx.

Code:
Copy      Help
str s="Balance (100)"
s.replacerx(".+?(\d+).*" "$1" 4)
out s

Here ".+?(\d+).*" ir regular expression.
.+? is 1 or more any characters. Matches "Balance (".
\d+ is 1 or more digits. Matches "100".
() marks the part of the string that can be specified as $1 in the replacement string.
.* is 0 or more any characters. Matches ")".


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)