Dan
Dan

Reputation: 255

Regexextract number just before specific text Google sheets

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.

Upvotes: 1

Views: 1012

Answers (1)

player0
player0

Reputation: 1

try:

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

enter image description here

Upvotes: 1

Related Questions