Error with REGEX.EXTRACT

I'm testing the formula in the screenshot below but I cannot understand why this isn't working. Every RegEx tester online suggests that this string should work. I'm expecting this formula to return 12. Any help on this is really appreciated!


=REGEX.EXTRACT(C3,"/(/d+)-(/d+)/g",1,1)


Posted on Feb 1, 2021 2:49 AM

Reply
Question marked as Top-ranking reply

Posted on Feb 1, 2021 5:22 AM

I am no expert on regular expressions but to get just the digits before the dash, a simple =REGEX.EXTRACT(C3,"\d+") should do the trick unless you only want it to return a result if the string is of the form you showed, digits a dash then more digits.


Other than that, it appears you used forward slashes, not the required backward slashes for your regular expression and the \g at the end (after correcting with a backward slash) fails for me.

3 replies
Question marked as Top-ranking reply

Feb 1, 2021 5:22 AM in response to ActuallyJack

I am no expert on regular expressions but to get just the digits before the dash, a simple =REGEX.EXTRACT(C3,"\d+") should do the trick unless you only want it to return a result if the string is of the form you showed, digits a dash then more digits.


Other than that, it appears you used forward slashes, not the required backward slashes for your regular expression and the \g at the end (after correcting with a backward slash) fails for me.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Error with REGEX.EXTRACT

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.