May 04, 2022 02:34 PM
I have a field called: Branch Name
I need to extract text from it using a formula field. I’m just not sure how.
Examples of data in the field:
#2828 - Clarksville Branch - Clarksville, TN
#4109 - Aiken Branch - Aiken, SC
What I need to extract:
Clarksville Branch
Aiken Branch
I tried this formula, but it doesn’t work (returns #ERROR!) and I don’t know enough about REGEX to troubleshoot:
REGEX_MATCH({Branch Name}, '/(?<=-).*(?=-)/g')
Solved! Go to Solution.
May 04, 2022 08:23 PM
Here’s a Regex solution:
IF({Branch Name}, TRIM(REGEX_EXTRACT({Branch Name}, " (?:\\b)([^-]*)")))
A couple of Regex tips:
REGEX_MATCH()
function only tells you if there is a match in the string. To extract, use REGEX_EXTRACT()
.May 04, 2022 05:50 PM
Hi @Cady_Smith1
REGEX will certainly be more concise but I dont know REGEX. Here is a formula that will work assuming the data is always formatted the same.
LEFT(MID(TRIM({Branch Name}),FIND("-", TRIM({Branch Name}))+1, LEN(TRIM({Branch Name}))),FIND("-", MID(TRIM({Branch Name}),FIND("-", TRIM({Branch Name}))+1, LEN(TRIM({Branch Name}))))-1,LEN(MID(TRIM({Branch Name}),FIND("-", TRIM({Branch Name}))+1, LEN(TRIM({Branch Name})))))
No doubt there is a better way to do it though.
May 04, 2022 08:23 PM
Here’s a Regex solution:
IF({Branch Name}, TRIM(REGEX_EXTRACT({Branch Name}, " (?:\\b)([^-]*)")))
A couple of Regex tips:
REGEX_MATCH()
function only tells you if there is a match in the string. To extract, use REGEX_EXTRACT()
.