I need a regex to extract the a portion of a string after 'n' occurrences of a particular character
For example the string is : "aa/bb/cc/dd/ee/ff/gg/hh/ii/jj/kk/ll/mm/nn/oo/pp" I need the content aa/bb/cc/dd/ee/ff
The followed the below approach but couldn't get the match. Please suggest i am wrong below
matcher = Pattern.compile("((?:[^/]*/){5})").matcher(regExString);
if (matcher.matches()) {
String str = matcher.group(1);
System.out.println(str);
}
try this
if (matcher.find()) {
String str = matcher.group(1);
System.out.println(str);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.