• +91 9723535972
  • info@interviewmaterial.com

Regular Expressions Interview Questions and Answers

Question - How to extract a substring using regex ?

Answer -

Example - String test = "This is a test String and 'This is data we want'"
A:
String data = "This is a test String and 'This is data we want'";
Pattern pattern = Pattern.compile("'(.*?)'");
Matcher matcher = pattern.matcher(data);
if (matcher.find())
{
    System.out.println(matcher.group(1));
}

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners