loading...

1.Introduction about Regex

shalya21 profile image Ayush Shalya ・1 min read

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.

Posted on by:

shalya21 profile

Ayush Shalya

@shalya21

I am a B.Tech student and I love to share my knowledge with everyone in a very simple an easy way.

Discussion

markdown guide