Hi all, need help create a search column REGEX to ...
# suitescript
d
Hi all, need help create a search column REGEX to capture everything after the last occurrence of " - " (spaceHYPHENspace)
So, for
0190 1st Ave - Napa - Sonoma, CA - The Palm
, I want to pull
The Palm
I'm close but just can't get it quite right
Copy code
([^\s-\s]*)$
This captures
Palm
Copy code
([^-]*)$
This captures
The Palm
(but includes a leading space
n
- (.+)$
maybe. i wrote that without testing
d
No, not quite @Nathan L
n
- ([^-]+)$ Second Try
d
Closer, that match 'includes' that spaceHYPHEN
n
last try then ill leave you alone lol
Copy code
(?<!-)- (?<= )([^-\n]+)$
d
No sir, thanks though
sadblob 1
a
does it NEED to be a regex?
r
something like this maybe?
Copy code
(?!.*-)[^\s].*$
🎉 1
m
@darrenhillconsulting You can use this (it uses .replace())
'0190 1st Ave - Napa - Sonoma, CA - The Palm'.replace(/ \- /g,'');
. If you are doing it using a FORMULA column, you should be able to use the REGEX_REPLACE function with something similar to this (Oracle SQL regex is formatted slightly differently though). Using .match() in Javascript is going to involves some painful things including back references, forward references, and named groups (so I wouldn't recommend it)
it also has nice non regular expression based answers
d
Thanks everyone. I went with
(?<= - )[^-]+$
... so the search formulatext looks like
REGEXP_SUBSTR({companyname}, '(?<= - )[^-]+$', 1, 1, NULL, 1)
👍 1