returns true if the string contains exactly "word" via regex - Java Regular Expressions

Java examples for Regular Expressions:Word

Description

returns true if the string contains exactly "word" via regex

Demo Code


public class Main {
  public static void main(String args[]) {

    String s = "main";
    s = s.toLowerCase();/*from ww w .  j  a v a 2  s .  c o m*/
    if (s.matches(".*main.*")) // returns true if the string contains exactly "main"
      System.out.println("found");
  }
}

Related Tutorials