I want to search for a given stringpattern in an input sting.
For Eg.
Now I need to search whether the string URL contains "/{item}/". Please help me.
This is an example. Actually I need is check whether the URL contains a string matching "/{a-zA-Z0-9}/".
I need to check this pattern "/{a-zA-Z0-9}/". The pattern should include two slashes and two braces. But the letters can be anything.
For eg: "/{asdFs7f}/", "/{asdfg}/", "/{ASDF}/", "/{23445}/".
Please help me suddenly.
Something like "/{[a-zA-Z0-9]+}/" should work as the pattern, although you may have to escape a few of the characters.
Harsha Smith
Ranch Hand
Joined: Jul 18, 2011
Posts: 287
posted
0
The following should be your regex. But as Tim suggested, reading java.util.regex API gives you better understanding why
it is written in such a way. check this link to know why the above poster asked you to escape some characters .
Java regex special characters