1.Introduction about Regex

Everything you need to know about Regex. (5 Part Series)

1 1.Introduction about Regex
2 2. The dot(.)
3 3.Matching digits and non digits character.
4 4. How to match whitespace and non whitespace characters.
5 5.How to match word and non word characters.

Regular expression is a sequence of characters used for searching of pattern or matching of pattern.
e.g : Regex Pattern :- Java
Test String :- Java , C and Python all are programming languages.

Sample code in java :

import java.io.;
import java.util.Scanner;
import java.util.regex.
;
class RegexSearch {
public void Pattern (String Regex_Pattern){
Scanner sc = new Scanner (System.in);
String Test_String = sc.nextLine();
Pattern p = Pattern.compile(Regex_Pattern);
Matcher m = p.matcher(Test_String);
System.out.println(m.find());
}
}
public class Main{
public static void main(String[] args){
RegexSearch obj = new RegexSearch();
obj.Pattern(“Java”);
}

Input: Java , C and python all are programming languages.
Output: true

You can view code here also.
Have a nice day , Coders.

Everything you need to know about Regex. (5 Part Series)

1 1.Introduction about Regex
2 2. The dot(.)
3 3.Matching digits and non digits character.
4 4. How to match whitespace and non whitespace characters.
5 5.How to match word and non word characters.

原文链接:1.Introduction about Regex

© 版权声明
THE END
喜欢就支持一下吧
点赞14 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容