i was wondering if the issue is visible for you guys, i have searched many 'a stackoverflow post but have failed to get an answer.
I'm trying to make a matcher that will eventually match C.V's and Job openings. Now I'm starting to learn about regexes and matching using aforementioned regexes. I am trying to get a successful match to get the feel of matching to eventually match those other things I mentioned, but now even the simple stuff isn't working.
public class RunMatchSequence {
public static void main(String[] args) {
try {
String emailRegEx = "(\\w+)@(\\w+\\.)(\\w+)(\\.\\w+)*";
// String emailRegEx = "(?s).*";
Pattern pattern = Pattern.compile(emailRegEx);
String target= "You can email me at [email protected] or [email protected] to get more info";
String target2="You can email";
java.util.regex.Matcher matcher; {
matcher = pattern.matcher(target);
while(matcher.find()) {
System.out.println("Found a Match" + Matcher.group());
System.out.println("Start position: " + Matcher.start());
System.out.println("End position: " + Matcher.end());
}}} catch (StackOverflowError e) {
System.out.println("Stackoverflow");
//JOptionPane.showMessageDialog(null, "Stackoverflow");
}
}
}
This being the class that runs the pattern. what follows is the class that holds the group, this is where the StackOverflowError occurs.(thinking its something to do with infinite recursion, but I have no idea how to solve it): EDIT: I now realize what caused the infinite recursion is the return statement, but i have no idea what to put there
public class Matcher{
public static void main(String[] args) {
RunMatchSequence.main(args);
//implements MatchResult {
// Pattern p = Pattern.compile("a*b");
// java.util.regex.Matcher m = p.matcher("aaaaab");
// boolean b = m.matches();
//}
}
static String group() {
// TODO Auto-generated method stub
return group();
}
static int end() {
// TODO Auto-generated method stub
return end();
}
static int start() {
// TODO Auto-generated method stub
return start();
}
}
group(),end(), andstart()supposed to be doing? You are correct that they result in infinite recursion. But what values are they supposed to be returning?return group()/end()/start();lines though. You're not going to get anywhere with them.