Home > Back-end >  Regexextract number just before specific text Google sheets
Regexextract number just before specific text Google sheets

Time:05-17

I need to extract the number that comes right before the text Positions

Example String:

Medical Specialist (Anaestheologist) (4 Positions) at Ministry

Valid Output should be 4

Example String 2 (If text Positions doesn't exist)

Medical Specialist (Anaestheologist) (4) at Ministry

Valid Output

4

I tried:

=REGEXEXTRACT(A24,"\(.*Positions.*\)") but it did not work.

CodePudding user response:

try:

=ARRAYFORMULA(REGEXEXTRACT(A1:A2; "(\d )(?: Positions)?"))

enter image description here

  • Related