正则表达式--find lookingAt
2016-06-03 10:47
375 查看
import java.util.regex.Matcher; import java.util.regex.Pattern; public class MainClass { public static void main(String arg[]) { String string="123-34345-234-00"; Pattern pattern = Pattern.compile("\\d{3,5}"); Matcher matcher = pattern.matcher(string); boolean result1= matcher.matches(); System.out.println("result1="+result1); //重置匹配器。 matcher.reset(); //尝试查找与该模式匹配的输入序列的下一个子序列。 boolean result2 = matcher.find(); System.out.println("result2="+result2); boolean result3 = matcher.find(); System.out.println("result3="+result3); boolean result4 = matcher.find(); System.out.println("result4="+result4); boolean result5 = matcher.find(); System.out.println("result5="+result5); //尝试将从区域开头开始的输入序列与该模式匹配。 boolean result6 = matcher.lookingAt(); System.out.println("result6="+result6); boolean result7 = matcher.lookingAt(); System.out.println("result7="+result7); boolean result8 = matcher.lookingAt(); System.out.println("result8="+result8); } }
result1=false result2=true result3=true result4=true result5=false result6=true result7=true result8=true
相关文章推荐
- GCD学习之Dispatch Group
- Android应用层View绘制流程与源码分析
- IntelliJ IDEA使用技巧
- HTML5见缝插针小游戏
- 虚拟内存简述
- linux登陆mysql数据库
- Example of ApplicationContextAware in Spring--转
- $.ajax,$.post,$.get的联系与区别
- GCD学习之dispatch_after
- Android4.4-Launcher源码分析系列之WorkSpace及屏幕滑动
- asp.net 加个弹出对话框
- Myeclipse提示:The import javax.servlet cannot be resolved
- 用鼠标拖动图片
- linux命令ps aux|grep xxx详解
- 购书策略
- GCD学习之dispatch_set_target_queue
- 仿IOS搜索框简单实现
- Android-分辨率以及dip(dp)、dpi、ppi、px、sp、pt说明
- android audio系统简记
- Android中系统名称、版本号以及相应的API Level