I selected a frame which has a character string like “$3.26%”
I’d like to have the number “3.26” without the $ and % and no extra spaces.
I tried Regex (with and without the “p”) on the internet but am pretty burnt out.
Also the string I’ve shown may not be fixed length so I simply want to eliminate the 1st and last character in the string.
Thanks a lot.
Mark
1 Like
Following regex should work in this case: \d+\.\d+
. In case you need to match that doesn’t have a decimal separator, you can use the following regex: \d+
Checkout https://regexr.com/. This makes testing and understanding regular expressions easier.
Feel free to reach out in case you have any questions or need any help.
1 Like
That worked like a champ. Thanks.
1 Like
Needed to precede it with a \- for negative numbers.
Great point. The \
is a escape character that is needed for a few escape characters like a dot or a slash. Following is another variant that can work in multiple cases in one shot:
[+-]?\d*\.?\d*
Following post on StackOverflow discusses a lot of aspects: regex - Regular expression for floating point numbers - Stack Overflow
Cheers!
1 Like