📜  使用正则表达式 java 代码示例进行拆分

📅  最后修改于: 2022-03-11 14:52:41.988000             🧑  作者: Mango

代码示例1
Pattern p = Pattern.compile("(\\d+)|([a-zA-Z]+)");
Matcher m = p.matcher("810LN15");
List tokens = new LinkedList();
while(m.find())
{
  String token = m.group( 1 ); //group 0 is always the entire match   
  tokens.add(token);
}
//now iterate through 'tokens' and check whether you have a number or text