Hi there,
I want to fix a Regex formula, but bumping into a challenge I can not fix.
We have a text field with a product name. This can be:
The Ultimate Workspace
The Ultimate Workspace - payment in 3 installments
I want a formula that extracts everything prior to " - …" (including the blank space in front of the hyphen. So the result will be “The Next Level”.
I have tried to make a ReplaceRegex myself. But can’t seem to get the desired outcome.
Chr1sG
July 19, 2023, 12:29pm
2
The result will be 'The Ultimate Workspace", no?
Chr1sG
July 19, 2023, 12:32pm
3
If you are sure that the first hyphen in the string is always the one you want to separate at, then I would suggest the following:
Left(TextField,Find(TextField,"-")-1)
Yes. We use with testing all those products interchangeably so accidentally misnamed.
PERFECT!!
Only challenge left. We sometimes have ‘The Ultimate Workspace’ and sometimes we have ‘The Ultimate Workspace - payment in 3 installments’.
If I use this formula, ‘The Ultimate Workspace’ will become ‘The Ultimate Workspac’ due to the -1. Tried to modify, but didn’t find the right solution.
Chr1sG
July 19, 2023, 1:02pm
6
Yeah, sorry.
You probably need something this then:
If(Find(TextField,"-")=0,TextField,Left(TextField,Find(TextField,"-")-1)
No sorry!
Was trying something like this, but because I wasn’t using the find function, my formula came up negative. This is perfect!
Thanks again.
Chr1sG
July 19, 2023, 1:11pm
8
Well, it actually can be done simply with regex replace as well.
ReplaceRegex(TextField, "-.*", "")
1 Like
Chr1sG
Split this topic
September 20, 2023, 6:07am
9
A post was split to a new topic: Extracting name from text