R-J
R-J

Reputation: 936

Regex for string that starts with a whitespace

I have a regex: \b[A-I]. .* Which searches for block like:

A. 1 to 2 
B. 2 to 3 
C. 3 to 4 
D. 4 to 5 
E. 5 to 6 

It must find only this block and nothing further in text. How can I force that this string is starting with whitespace?

Example here: https://regex101.com/r/oW6iP9/1

Upvotes: 0

Views: 73

Answers (2)

JotaBe
JotaBe

Reputation: 39004

This expression will work for you

^[A-I]\. .*/gm

^ is the beginning of line, which must be combined with the m (multiline) option, so that each single line in the text is considered separatedly

\. use this instead of ., so that is interpreted as dot, and not as any character

.* will match everything but end of line, so that each match will end at the end of each line

Upvotes: 0

Avinash Raj
Avinash Raj

Reputation: 174696

Think you mean this.

/^[A-I]\. .*/m

DEMO

Upvotes: 1

Related Questions