Thursday, 9 February 2023

Constructing regex pattern to match sentence

 

Constructing regex pattern to match sentence

 

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"

 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Blog Archive