作者:millottgerould | 来源:互联网 | 2023-10-11 16:37
本文主要分享【java中matches怎么进行比较的】,技术文章【JavaMatcher.lookingAt()方法具有什么功能呢?】为【qq_25073223】投稿,如果你遇到java相关问题,本
本文主要分享【java中matches怎么进行比较的】,技术文章【Java Matcher.lookingAt()方法具有什么功能呢?】为【qq_25073223】投稿,如果你遇到java相关问题,本文相关知识或能到你。
java中matches怎么进行比较的
转自:
Java Matcher.lookingAt()方法具有什么功能呢?
下文笔者讲述Matcher.lookingAt()方法的功能简介说明,如下所示:
Matcher.lookingAt()方法的功能: 对字符串进行匹配,只要匹配到字符串,则返回true Matcher.lookingAt()方法的语法: public boolean lookingAt()
例:
package com.java265.other;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class testDom4J {
/*
* java265.com Pattern类的使用
*/
public static void main(String[] args) {
Pattern p = Pattern.compile("([a-z]+)");
Matcher m1 = p.matcher("java265.com");
Matcher m2 = p.matcher("java");
System.out.println("m1:" + m1.lookingAt());
System.out.println("m2:" + m2.lookingAt());
}
}
-----运行以上代码,将输出以下信息----
m1:true
m2:true
本文《Java Matcher.lookingAt()方法具有什么功能呢?》版权归qq_25073223所有,引用Java Matcher.lookingAt()方法具有什么功能呢?需遵循CC 4.0 BY-SA版权协议。