Home > Software design >  Regex to test if a string starts with all caps words terminated by semi-colon [closed]
Regex to test if a string starts with all caps words terminated by semi-colon [closed]

Time:09-16

I need to find if a string starts with all caps words (one or more) and the all caps sequence of words ends with :

START: bla bla 123 ;4@^:. - good
START OF THE LINE: bla bla 123 ;4@^:. - good
START 4: bla bla 123 ;4@^:. - bad
The START - bad

CodePudding user response:

/^[A-Z\s]*:/mg

^ matches at the start of the line

[A-Z\s]* match all capital letters plus spaces

: match the semicolon symbol

  • Related