“Ekspresi reguler Java” Kode Jawaban

Ekspresi reguler Java

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
  public static void main(String[] args) {
    Pattern pattern = Pattern.compile("w3schools", Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher("Visit W3Schools!");
    boolean matchFound = matcher.find();
    if(matchFound) {
      System.out.println("Match found");
    } else {
      System.out.println("Match not found");
    }
  }
}
// Outputs Match found
naly moslih

Java Regex

Pattern pattern = Pattern.compile("1");
Matcher matcher = pattern.matcher("111");
while (matcher.find()) {
    System.out.println(matcher.group());
}
Annoying Anteater

Jawaban yang mirip dengan “Ekspresi reguler Java”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya