Home > Blockchain >  RegexExtract Syntax - Extract text after decimal/number from string ex. "UNDER 12.5-120"
RegexExtract Syntax - Extract text after decimal/number from string ex. "UNDER 12.5-120"

Time:09-15

I am trying to write a RegexExtract formula to extract the odds of a bet.
My example text is UNDER 12.5-120.
In this example, I would hope to return -120 but I need my equation to be dynamic enough to extract other odds as well.
More examples of this would be 120, 1200, 12000, -1000, etc etc.
The string will always be in this order though - OVER or UNDER then the line of the bet and then the odds of the bet. I have successfully written the regex for the line and the over/under but cant figure out the odds portion.

This is what I have so far:

=REGEXEXTRACT('Form Responses 2'!C2,"[\d.,].*") but this returns 12.5-120 and I need only the -120.

CodePudding user response:

Try this for a range

=INDEX(IFERROR(REGEXEXTRACT(Q2:Q8,"[-| ]\d ")))

If you want to have pure numbers try

=INDEX(IFERROR(REGEXEXTRACT(Q2:Q8,"[-| ]\d ") 0))

enter image description here

CodePudding user response:

This ended up working for me!!!

=REGEXEXTRACT('Form Responses 2'!C2,"[-| ][\d] ")
  • Related