java正则”组”例子


		String accessRegex = ".*userNameId\\-(\\d+).*";
		String text = "2012-10-26 14:41:30,748  userNameId-777 from IP-10.232.25.144 invoked URL-http://xxx/hello.jsonp";

		Pattern pattern = Pattern.compile(accessRegex);
		Matcher matcher = pattern.matcher(text);
		if (matcher.find()) {
			System.out.println(matcher.group(1));
		}

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.