Reputation: 40513
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
Upvotes: 0
Views: 676
Reputation: 112230
If you need to check if "MenuTest" appears at that specific position (i.e. after the host/port), then you can use:
^https?://[^/]++/MenuTest
Upvotes: 1
Reputation: 342765
Maybe you don't need a regex?
String url = "http://localhost:8080/MenuTest/index.action";
boolean hasWhatImLookingFor = url.contains("MenuTest");
Upvotes: 9
Reputation: 13637
The regex you seek is simply "MenuTest", without the quotes. Unless the question is more complex than it appears?
Upvotes: 0
Reputation: 1900
Something along these lines? (untested)
Regex r = new Regex("MenuTest");
r.search("http://localhost:8080/MenuTest/index.action");
System.out.println(""+r.didMatch());
Upvotes: 0