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.
The dot(.) matches anything except a new line.
e.g : Regex Pattern :- .
Test String : Hi everyone.
Sample code in java:
import java.io.;
import java.util.Scanner;
import java.util.regex.;
public 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);
while(m.find()){
System.out.print(m.group());
}
}
}
public class Main{
public static void main (String[] args){
RegexSearch obj = new RegexSearch();
obj.Pattern(“.”);
}
}
you can view the code here also.
Do read my first article about regex.
1.Introduction about Regex
Ayush Shalya ・ Mar 29 ’20 ・ 1 min read
#regex #java
原文链接:2. The dot(.)
暂无评论内容