Answers for "how toe extract html tags form strings in java using regex"

0

how toe extract html tags form strings in java using regex

import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ExtractHtmlTag {
   public static void main(String[] args) {
      String str = "Welcome to <b>Tutorialspoint<b>";
      //Creating a pattern object
      Pattern pattern = Pattern.compile("<b>(\\S+)</b>");
      //Matching the compiled pattern in the String
      Matcher matcher = pattern.matcher(str);
      if (matcher.find()) {
         String result = matcher.group(1);
         System.out.println(result);
      }
   }
}
Posted by: Guest on July-06-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language