Jack Bush wrote:
Hi All,
I would like your advice on how to mask out / ignore a string that does not match a well established working regular expression pattern in Java.
Below is the code snippet that matches all the lines with correct regular expression string except one found so far:
The difference between correctPropertyDetail and incorrectPropertyDetail is the ‘S’ after Rose St. A sample of few hundred lines of data has been picked up properly but a few incorrect ones managed to slipped through. Neither pattern1 nor 2 achieve the desired objective.
I am running JDK1.6.0_25, Netbeans 7.0 on Windows XP.
Your assistance would be appreciated.
Thanks,
Jack
Jack Bush wrote:
Hi James,
Thank you for offering your valuable advice. I have made the suggested changes
but it still picked up the same incorrect string with an extra 'S'. As a result, I have applied the same suggestion throughout the rest of the regular expression which successfully prevented the incorrect string from coming through (great!), but also stopped many correct ones from being accepted. Below is the newly modified regular expression used?
Note that it is the second sub-pattern “(?:[A-Z]?[0-9]{0,4}/?[0-9]{0,4}-?[0-9]{0,4}|[0-9]{0,4}[a-z])” that is responsible for making it work, yet also breaking the regular expression by not accepting the good strings as well. Some of the good strings include the example provided earlier. Can you see what is wrong with it?
I no longer have confident in myself who was responsible for coming up with a half baked, ordinary regular expression, largely due to a lack of familiarity with this subject. Instead, you are the competent person who can help me get just this one pattern working.
I am a novice amateur programmer and do not have resource and time to come up with a BNF specification, even though that would be an ideal situation especially in large project.
Again, your advice would be appreciated.
Thank
Jack
I carry this gun in case a vending machine doesn't give me my fritos. This gun and this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|