2

I need help with the following Apple Numbers REGEX.EXTRACT formula that doesn’t return the word before a dot. Below are the text form of the arguments passed to the formula and the formula itself as well as a screenshot.

Pattern: \b\w+\b(?=\.)
String: 123. xpto.
Formula: REGEX.EXTRACT(“123. xpto.”, `\b\w+\b(?=\.)`,1)

why “123” not “xpto”

2
  • What do you expect here? What are you trying to do? Please provide more detail to help others help you.
    – Thinkr
    Commented Jun 25, 2023 at 10:21
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Jun 25, 2023 at 11:41

2 Answers 2

0

I found two following solutions. I prefer lookaround for shorter formula.

solution with and without look around

0
0

If I understood well, you want to return any word that is immediately followed by a dot in a given string. In the example you provided, the function

REGEX.EXTRACT(“123. xpto.”, `\b\w+\b(?=\.)`,1)

should return "The formula contains a syntax error", since the Regex's syntax is incorrect.

Here is how your Regex parameter should look like: (\b\w+\b)\. Adding parentheses around \b\w+\b make it capture the entire word before the dot. You also need to encapsulate the Regex with double quotes (no single quotes or tildes).

The modified function would look like this:

Regex.Extract("123. xpto.", "(\b\w+\b)\.", 1)

And it should return "123."

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .