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

  1. \\.\\w[a-z]
  2. \\.\\s\s[a-z]
  3. \\.(?!\\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

Popular posts from this blog

matlab - Deleting rows with specific rules -

image - ClassNotFoundException when add a prebuilt apk into system.img in android -