This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
Looks aren't everything... But the latest Community refresh looks darn good!
Need a small help on regex:-
I have a field called XXX having different length at row level. I want to remove all rows where "D" OR "D1234" is reflecting at the end of the rows.
I want to remove "D" & "D1234" from end of the above rows.
Please suggest how to remove using Regex or any other way.
Go to Solution.
Go to Solution.
So remove anything after the last D?
Or in another way, keep everything before the last D?
Yes you are correct.
Remove D from the last or keep before D
I've chosen the 'Other Way' option...
Use a formula tool with the following statement, where Field1 represents the field you want to do this against.
Essentially it finds the position of the last instance of the character D, and then gets us everything to the left of that.
The formula is not working correctly. Incase of below record, it should be no change as D is not at the end. However, its showing like:
One Quick fix for the formula could be to add an if sentence before the formula and only run it, if your condition (field ends in D OR D1234) is met. Something like this:
IF Right([Field1], 5) = "D1234" OR Right([Field1], 1) = "D" THEN
ELSE [Field1] ENDIF
This would be my REGEX solution:
REGEX_Replace([Field1], "^(.*)(D|D1234)$", "$1")