KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to capture the right part after the : using java expr, but in the following code, the printed capture group is the whole string, what's wrong? String s ="xyz: 123a-45"; String patternStr="xyz:[ \\t]*([\\S ]+)"; Pattern p = Pattern.compile(patternStr); Matcher m = p.matcher(s); //System.err.println(s); if(m.find()){ int count = m.groupCount(); System.out.println("group count is "+count); for(int i=0;i<count;i++){ System.out.println(m.group(i)); } }
Tags (comma-separated)
Save Edits
Cancel