Skip to content

Instantly share code, notes, and snippets.

@masudak
Created October 2, 2015 01:56
Show Gist options
  • Save masudak/4d79dba525ce18149540 to your computer and use it in GitHub Desktop.
Save masudak/4d79dba525ce18149540 to your computer and use it in GitHub Desktop.
public static void main(String[] args) {
String str = "2009time";
String regex = "(\\d+)(t)";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(str);
if (m.find()) {
String matchstr = m.group();
System.out.println(matchstr + "の部分にマッチしました");
System.out.println("group1: " + m.group(1));
System.out.println("group2: " + m.group(2));
}
}
@masudak
Copy link
Author

masudak commented Oct 2, 2015

2009tの部分にマッチしました
group1: 2009
group2: t

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment