package com.livingforu.test0010;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* @author Administrator
* 找出字符串中最长的,打印出来并打印该字符串在整个字符串的位置和长度
*/
public class BeiNuee{
public static void main(String[] args)
{
String s = "adfadf12311sdfsd123123fsdfd233";
zhengze(s);
}
public static void zhengze(String s){
Pattern p = Pattern.compile("(\\d+)", Pattern.DOTALL);
Matcher matcher = p.matcher(s);
//List<String> sList = new ArrayList<String>();
String maxs = "";
while (matcher.find())
{
if(maxs.length() < matcher.group(1).length())
{
maxs = matcher.group(1);
}
}
System.out.println(maxs);
System.out.println(maxs.length());
System.out.println(s.indexOf(maxs));
}
}