Constructing regex pattern to match sentence

java, regex

Solution

String regex = "^\\s+[A-Za-z,;'\"\\s]+[.?!]$"

`^` means "begins with" `\\s` means white space `+` means 1 or more `[A-Za-z,;'"\\s]` means any letter, `,`, `;`, `'`, `"`, or whitespace character `$` means "ends with"

Problem

I'm trying to write a regex pattern that will match any sentence that begins with multiple or one tab and/or whitespace. For example, I want my regex pattern to be able to match " hello there I like regex!" but so I'm scratching my head on how to match words after "hello". So far I have this: ``` String REGEX = "(?s)(\\p{Blank}+)([a-z][ ])*"; Pattern PATTERN = Pattern.compile(REGEX); Matcher m = PATTERN.matcher(" asdsada adf adfah."); if (m.matches()) { System.out.println("hurray!"); } ``` Any help would be appreciated. Thanks.

Original source