-2

i have some trouble with this reg exp case :

Text: COSAAATANZOSALVAOOOTORRRE

Reg Exp C[A-Z]*S[A-Z]+T?

this give me this match

COSAAATANZOSALVAOOOT

but i need this match:

COSAAAT

how i can do it?

Salvosnake
  • 83
  • 10
  • I think `(#)` should not be part of the regex, but you can make the quantifiers non greedy `C[A-Z]*?S[A-Z]+?T` https://regex101.com/r/JxApPK/1 – The fourth bird May 03 '21 at 15:45

1 Answers1

0

You can make you quantifiers lazy by adding a ?. Like so:

C[A-Z]*?S[A-Z]+?T
deltini
  • 9
  • 1