Hi All, I want to perform this type of filtering in Regex or filter tool. if there's an "R" before the numbers, then keep R, numbers, and ".", but remove all letters after numbers. Appreciate all th
I want it to be like:
inputs:
123.3QBS
R1232
1234
1234.2
R123.2ABC
outputs:
123.3
R1232
1234
1234.2
R123.2
Solved! Go to Solution.
I like to use regex101.com to test my regular expressions. You can use the Parse function in the RegEx tool to accomplish this.
Here's what I came up with: (^R*\d+\.*\d*).*
Anything inside the parentheses is going to get be kept. Everything outside is not going to be parsed. I'm identifying the "R" at the beginning of the word by using the "^", then R is quantified using "*", which means that it occurs zero to infinity times. After that, "\d" represents any digit and it's quantified using "+" which means it occurs at least once to infinity times. Then comes the "\." which represents the actual period, instead of what "." represents in a regular expression and it's quantified by "*" which means that period occurs zero to infinity times. The last part is "\d*" which signifies that I'm looking for between no digits and infinity digits and I'm not looking for anything else after it. Don't forget to rename your field from "RegExOut1."
Regex101.com is amazing and it's a great site to use when you're learning RegEx. Go ahead and test it out yourself and let me know if you have any questions.
To contribute to the discussion, here is another way to do it in REGEX:
(\d+\.\d+|\d+\.?\d*[A-Za-z]+|\d+)
Hope this helps too @davidi123 !
Here is my solution: