views:

754

answers:

1

from the following strings:

"details.php?news=13&action=main&menu_type=&option=single&news_id=4792&pub_no=50"

Is this possible in String str.contains(strcase)

where strcase="details.php", "news_id" can both be checked at the same time.

Not like: str.contains("details.php")&&str.contains("news_id").

both cases should be taken to the strcase="details.php ** news_id"

Like this statement :

str.replaceAll("\\<[^>]*>","");

can strip out tag "<?>".

+5  A: 

string.contains() does not match regular expressions, so you cannot use it like str.replace().

You could use string.matches() though, as it does accept regular expressions.

str.matches(".*details\\.php.*news_id.*");

**Disclaimer** I suck at regular expressions, but that should be close to what you want.

jjnguy
Yep, looks good to me, as long as "details" really has to be the first thing in the string. Otherwise, you'll need another `.*` in there.
Michael Myers
good call, I wasn't sure, but it shouldn't hurt.
jjnguy
Thanks a lot.... :D:D:D
Jammin
You are welcome. Feel free to check that magical accepted check mark if you want! `:P`
jjnguy
Just FYI, `replace()` doesn't use regexes either; it's `replaceAll()` you're thinking of.
Alan Moore