[SalesForce] Formula to extract numeric values from text field based on condition

I'm trying to write a formula to get the number value from a string. The issue is that the text field varies, see examples below:
Example 1: Quote 1
Example 2: Quote 2 copy
Example 3: Quote 10
Example 4: copy of copy of Quote 1 of Copy 1

I only need to get the number that follows the word "Quote" if the text only contains the word "Quote". If the text contains the word "Quote" and "Copy", then it should display as 0

Best Answer

VALUE(RIGHT(MID(textFld,FIND(textFld,'Quote'),7),1))
  • FIND locates the string 'Quote'
  • MID extracts the string 'Quote n'
  • RIGHT extracts the digit n as a string
  • VALUE converts to a number

If n is more than a single digit, then replace the '7' above with an expression that finds the end of the quote#