Regular expression matches multiple lines in Java

Pattern.MULTILINE will help on matching multiple lines in java. below is an example to show this −

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

public class MultiRegex {

   public static void main(String[] args) {
      if (args.length<1) {
         System.err.println("run the program from command line");
      String regexString = args[0];
      String spamString = "welcome to java world";

      Pattern aPattern = Pattern.compile(regexString,Pattern.MULTILINE);
      Matcher aMatcher = aPattern.matcher(spamString);
      if (aMatcher.find()) {
         System.out.println("got a match");
      } else {
         System.out.println("no match");