loading...

2. The dot(.)

shalya21 profile image Ayush Shalya ・1 min read

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.

Discussion

markdown guide