I want to do pattern matching using java. My string is (a<b) I tried with the following patterns. [(][a][<][)]$ and [(][a][/<][)]$ but these patterns doesn't match. can any one tell me how to match operators like < , >, <=, >=, + .. Thank u..
Try this Code: \([a]<[b]\) Operators are matched like normal characters, for more info try http://regularexpressions.info
Here's an example of using Regular Expressions in Java Code: // Compile regular expression String patternStr = "b"; Pattern pattern = Pattern.compile(patternStr); // Determine if there is an exact match CharSequence inputStr = "a b c"; Matcher matcher = pattern.matcher(inputStr); boolean matchFound = matcher.matches(); // false // Try a different input matcher.reset("b"); matchFound = matcher.matches(); // true // Determine if pattern matches beginning of input matchFound = matcher.lookingAt(); // false
Hi I need to check for a PO Box addresses in a string. I should not allow a pobox in a address Line. For that I need a pattern and willl match this pattern with my string Ex:***** something like this ****** Pattern poBoxPattern = Pattern.compile("\\bp\\s*\\d") .... Matcher matcher = poBoxPattern.matcher(locationAddressStreet); if(matcher.find()){ } So, could anyone help me with making the pattern. My pattern should recognize sub strings like... 1. po 123 ( meaning: po followed by any integer/integers ) 2. p o 123 3. p.o. 123 4. p. o. 123 5. po box 6. po box 7. p o box 8. p o 123 Note: "po sometext" or "p o sometext" should not be recognized. Any help is truly appreciated. Thanks Sai
sssrsl, have a separate thread for the query as that will give more visibility to experts as well as help others to search.