regex - Split the given text based on pattern java -
below text
this first java program. new java program. program running without any. issues.
it should split
this first java program. new java program. program running without any. issues. all.
the regex should take below pattern
1.dot 2.followed space 3.followed capital letter word(not lowecase)
i tried this
\\.\\w[a-z]
\\.\\s\s[a-z]
\\.(?!\\w)
but failed it.
try following code:
string text = "this first java program. new java program. program running without any. issues. all"; pattern pattern = pattern.compile("(?<=\\.)\\s+(?=[a-z])"); string[] lines = pattern.split(text); (string line : lines) { system.out.println(line); }
output:
this first java program. new java program. program running without any. issues.
Comments
Post a Comment