How do I match the following string?
http://localhost:8080/MenuTest/index.action
The regex should return true if it contains "MenuTest" in the above pattern.
Cheers
How do I match the following string?
http://localhost:8080/MenuTest/index.action
The regex should return true if it contains "MenuTest" in the above pattern.
Cheers
Something along these lines? (untested)
Regex r = new Regex("MenuTest");
r.search("http://localhost:8080/MenuTest/index.action");
System.out.println(""+r.didMatch());
Maybe you don't need a regex?
String url = "http://localhost:8080/MenuTest/index.action";
boolean hasWhatImLookingFor = url.contains("MenuTest");
The regex you seek is simply "MenuTest", without the quotes. Unless the question is more complex than it appears?
If you need to check if "MenuTest" appears at that specific position (i.e. after the host/port), then you can use:
^https?://[^/]++/MenuTest