detecting specific values in a text file......

Hi all,

The scenario....... a developer uses a tool like DreamWeaver to generate a series of HTML pages. Later, the code is run through a scanning tool to assure that all of the tags are compliant to specific rules. The code fails miserably. Some of the errors r false positives while still others are actual errors. Proposed solution....... Run the file through a process that will locate the tags that are in violation and replace them with valid tags. Can someone suggest for me what classes I might look to for assistance in parsing the file for certain character(s) and replacing them with other certain character(s). Any other suggestions for a solution would be welcome......

Regards,

Mat

[727 byte] By [MatLL] at [2007-9-26 4:21:45]
# 1

Hey Mat,

You can look at the java.util.regex package. The Pattern and Matcher classes are powerful text string matches. The Matcher class will also replace a certain string with another, if the certain string matches the pattern you are looking for, for instance the pattern <\w+> will match any starting HTML tag "<html>", while <\/w+> will match an ending HTML tag "</html>".

Hope this helps

Bud

BudT at 2007-6-29 17:26:12 > top of Java-index,Archived Forums,Java Programming...
# 2

Apache's Jakarta project also hosts a couple of java packages for regular expression support, namely OROMatcher and RegExp. I've had a great deal of success with the OROMatcher, which uses perl-like regular expression syntax.

You can find them both at http://jakarta.apache.org

cbacher at 2007-6-29 17:26:12 > top of Java-index,Archived Forums,Java Programming...