How to split the string with bullets(All types)using regex in java -


below text

 welcome java programming 1) oops concepts a) encapsulation a) abstraction i) inheritance  • polymorphism 2)sample program on java 1.project source code  sample text files • sample.txt b)sam.txt 

i want split text based on below pattern , remove bullets

1)any bullet 1)i)a)a)• 2)followed space 3)followed uppercase word 

so want generate following result

welcome java programming  oops concepts  encapsulation  abstraction inheritance   polymorphism sample program on java project source code please suggest me how sample text files sample.txt 

sam.txt thanks

following positive lookahead based regex should work you:

string s = "welcome java programming 1) oops concepts a) encapsulation a) abstraction i) inheritance  • polymorphism"; string[] arr = s.split("\\s*([a-za-z\\d][).]|•)\\s*(?=[a-z])"); system.out.println("split => " + arrays.tostring(tok)); 

output:

split => [welcome java programming, oops concepts, encapsulation, abstraction, inheritance, polymorphism] 

Comments

Popular posts from this blog

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

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -