/home/index.do
/home.do
The following pattern I would assume should work. It works in PHP when I use preg_match(), adding delimiters of course.
Code: Select all
Pattern p = Pattern.compile("^/([^/]+)(/|\\.do$)");EDIT | Hmm, even just using the pattern:
^/([^/]+)
On the string
/home/index.do
Fails. Either I need to go to bed, or this makes no sense at all
//Straight off the command-line, hard-coded proof
Code: Select all
chris-corbyns-computer:~/Java d11wtq$ cat Re.java
import java.util.regex.*;
class Re {
public static void main(String[] args) {
Pattern p = Pattern.compile("^/([^/]+)");
Matcher m = p.matcher("/home/index.do");
if (m.matches()) {
System.out.println("It matches");
} else {
System.out.println("NO MATCH");
}
}
}
chris-corbyns-computer:~/Java d11wtq$ javac Re.java
chris-corbyns-computer:~/Java d11wtq$ java Re
NO MATCH
chris-corbyns-computer:~/Java d11wtq$