DEV Community

Ayush Shalya
Ayush Shalya

Posted on

2. The dot(.)

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.

Top comments (0)