Java matches() 方法
Java 教程
· 2019-02-08 23:12:26
matches() 方法用于检测字符串是否匹配给定的正则表达式。
调用此方法的 str.matches(regex) 形式与以下表达式产生的结果完全相同:
Pattern.matches(regex, str)
语法
public boolean matches(String regex)
参数
regex -- 匹配字符串的正则表达式。
返回值
在字符串匹配给定的正则表达式时,返回 true。
实例
public class Test {
public static void main(String args[]) {
String Str = new String("www.codercto.com");
System.out.print("返回值 :" );
System.out.println(Str.matches("(.*)codercto(.*)"));
System.out.print("返回值 :" );
System.out.println(Str.matches("(.*)google(.*)"));
System.out.print("返回值 :" );
System.out.println(Str.matches("www(.*)"));
}
}
以上程序执行结果为:
返回值 :true 返回值 :false 返回值 :true
点击查看所有 Java 教程 文章: https://codercto.com/courses/l/12.html
jQuery实战(第2版)
[美]Bear Bibeault、[美]Yehuda Katz / 三生石上 / 人民邮电出版社 / 2012-3 / 69.00元
jQuery 是目前最受欢迎的JavaScript/Ajax 库之一,能用最少的代码实现最多的功能。本书全面介绍jQuery 知识,展示如何遍历HTML 文档、处理事件、执行动画、给网页添加Ajax 以及jQuery UI 。书中紧紧地围绕“用实际的示例来解释每一个新概念”这一宗旨,生动描述了jQuery 如何与其他工具和框架交互以及如何生成jQuery 插件。 本书适合各层次Web 开发人......一起来看看 《jQuery实战(第2版)》 这本书的介绍吧!