hi,
i am having an doubt in pattern.compile while using that regular expression i have some doubt. my doubt is that in this
Pattern pattern = Pattern.compile("(Java|JavaProgramming) (has|have) methods");
i have (Java|JavaProgramming) and (has|have)
i need to declare that Java|JavaProgramming and has|have
if i give
String deceleration like this
String regex = "Java|JavaProgramming";
String regex1 = "has|have";
i want this to have declared be common name instead if that pattern.compile
can any one tell me how to declare it in program some where and not in that pattern.compile??
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Matching_Casesensitive {
public static void main(String[] args) {
Pattern pattern = Pattern.compile("(Java|JavaProgramming) (has|have) methods");
String text="Java has methods\n"
+ "JavaProgramming have methods\n";
System.out.println("Words from the Text is:-");
System.out.println(text);
System.out.println("========================");
Matcher m = pattern.matcher(text);
System.out.println("Finded words from the Text is:-");
while (m.find())
System.out.println(m.group());
}}