Expression to extract text in a string to the right after a dash character
I need to extract text in strings (product labels) after a dash character. An example string: Pavé Nameplate Necklace - "ADHD". Ideally, the result would be ADHD, but "ADHD" works as well, since I will use the extracted text to sort alphabetically.
I'm avoiding extracting text between quote marks since many of the label-strings have inconsistent straight-quote marks and smart-quotes marks --but maybe an expression can account for the different quote mark styles.
Thanks in advance!
Bob
33 replies
-
Is the text after the dash always four letters?
Or
Is there another pattern after the dash?
-
Here is a quick and dirty regex code that searches for both double quotes and curly double quotes, but I don't know how to put double quotes into extractx() since Ninox thinks they are Ninox code.
Once someone smarter can tell us how to escape double quotes, then you can put both results into a JSON like shown in this response.
Then you can filter the JSON to get the correct response.
-
Unfortunately the text afterward varies, sometime multiple words. But since I'm only using this for sorting alphabetically, maybe using the first four letters would work.
-
said:
Unfortunately the text afterward varies, sometime multiple words.Do the multiple words exist outside the quotes?
Here is something that will work easily in extractx() but will give you the quotes.
(?<=- )(.*)
This will give you everything after the dash and space.
So something like:
extractx(fieldName, "(?<=- )(.*)", "$1")
But you still have quotes to deal with.
-
I'll give it a shot. Unclear whether or not if including the quotes (what ever version) will change the sorting.
-
I get a syntax error message: #ERR: SyntaxError: Invalid regular expression: invalid group specifier name. Sorry, regex code is beyond me, so I need help debugging.
-
-
"Do the multiple words exist outside the quotes?" --didn't respond to your question ... yes there are multiple words before the dash, actually 3 with spaces in between. It would be fairly easy to make all the same, if that helps.
-
try:
replace(substr(YourTextField, index('Text 2', "-") + 1), """", "")
Content aside
- Status Answered
- 9 mths agoLast active
- 33Replies
- 413Views
-
5
Following