troubleshooting Question

Need pattern string occured from the regular expression

Avatar of Suda_RamanaReddy
Suda_RamanaReddy asked on
JavaRegular Expressions
12 Comments1 Solution442 ViewsLast Modified:
Hi All,

I am splitting a string based on regular expression..... which looks like below.

public List splitString (String str, String regularExp){
 // Doing splitting and segregating it to chunks...
String [] splitArrey = str.split(regularExp);

// Want to get the actual pattern occuring each time...

Invoking above method
String regEx =  "<?(br|p|-- end --)>"
List resultList = new Splitter.splitString (str, regEx);

All I need in the above method now I want to find out what is the mattching pattern occured. Say it could be <br> or <p> or could be <-- end -->.

When I try to access the pattern String I'm getting the regular Expression I passed.. Instead I want to get the actual pattern string which was occured.. because I need to add that pattern string at the end of my chunk.

All I need is to access the pattern string which is splitting the string.... is there any method to get it...

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros