Search code examples
regexgoogle-sheetsgoogle-sheets-formula

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


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.


Solution

  • 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