I need to check if the value of one String is contained in another. Consider the following- String strAddress = "123 Main street, P.O Box 456"; String strInvalid = "P.O Box"; I need to compare the two to determine if strAddress contains strInvalid anywhere in it. Note: in reality, i would have to check for multiple formats of strInvalid Strings. e.g. "P.O Box" , "PO.Box" , "P O Box"...etc Would appreciate any help/advice in getting this done. Thanks :roll:
SCJP.<br />I haven't lost my mind, it's backed up on a disk somewhere!
Hi um .. Jumpin'. (You want to change that before the sheriff gets after you.) As for your problem, it sounds like you wouldn't be able to use any useful String methods unless you checked each one. So, I would say your next bet is the use of regular expressions. Have you looked into that?
(You want to change that before the sheriff gets after you.)
... IIIII shot the sheeeeriffff .... but i did not kill the....
use of regular expressions
Nope have not done that yet, but thanks for the tip and the quick response. If you have anything specific i should investigate, please let me know.' Thanks again. [ April 22, 2004: Message edited by: Jumpin' Java ]
the Sheriffs 'round here are terrible creatures, and very mean, and they have big teeth, and they eat babies. The bartenders are very cool, OTOH. Very cool. However, we both need to enforce a naming policy, so please come up with a plausible (non-fictional-sounding, non-famous) first name and last name, and I'll buy you a beer. In the meantime, do a search on regular expressions on this forum, and you'll get what you want. As a quick start, try the following.
HTH, M [ April 22, 2004: Message edited by: Max Habibi ] [ April 22, 2004: Message edited by: Max Habibi ]