// Java code to illustrate find() method
import java.util.regex.*;
public class GFG {
public static void main(String[] args)
{
// Get the regex to be checked
String regex = "Geeks";
// Create a pattern from regex
Pattern pattern
= Pattern.compile(regex);
// Get the String to be matched
String stringToBeMatched
= "GeeksForGeeks";
// Create a matcher for the input String
Matcher matcher
= pattern
.matcher(stringToBeMatched);
// Get the subsequence
// using find() method
System.out.println(matcher.find());
find/match pattern in string
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 运行以下核心代码有警告信息: Use of uninitialized value $_ in patt...
- 错误原因: 过程ViewController渲染的时候,系统默认StatusBar是NO,IOS StatusBa...
- 找到提供的句子中最长的单词,并计算它的长度。函数的返回值应该是一个数字。当你完成不了挑战的时候,记得开大招'Rea...
- 1 因为anagram是字符的不同排列,所以只需用一个dictionary来存储每个字符出现的次数,pCounte...