做课程项目(北大燕园教室查询模块)过程中,遇到一个小问题,需要从字符串中提取一下数字。记录一下。

 

String str = "一教楼101室"
Pattern p = Pattern.compile("\\d+");
Matcher m = p.matcher(str);
m.find();
System.out.println(m.group());//output is 101

Leave a Reply

Your email address will not be published.

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