> Hi,
>
[quoted text clipped - 17 lines]
>
> // Create the pattern
Pattern pattern1 = Pattern.compile(patternStr1);
Pattern pattern2 = Pattern.compile(patternStr2);
Matcher matcher1 = pattern1.matcher("");
Matcher matcher2 = pattern2.matcher("");
// Retrieve all lines that match pattern
String line = null;
while ((line = rd.readLine()) != null)
{
matcher2.reset(line);
matcher1.reset(line);
if (matcher2.find() || matcher1.find())
> // line matches the pattern
> }
[quoted text clipped - 7 lines]
>
> //mikael
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
IchBin - 19 Jun 2006 20:22 GMT
>> Hi,
>>
[quoted text clipped - 34 lines]
>> } catch (IOException e) {
>> }
Also take a look at this "Implementing a FilterReader to Filter Lines
Based on a Regular Expression" in the The Java Developers Almanac
http://javaalmanac.com/egs/java.util.regex/LineFilter2.html
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
> Hi,
>
[quoted text clipped - 4 lines]
> I am not sure how I can create two patterns to search for in the same
> file.
In this case you should be able to use a single pattern. The trivial way
to search for two possibilities is to just use or as in
"DONUMBER|DO_NUMBER".
But in this case you can instead use "DO_?NUMBER".
> Also what is the difference between the pattern and matcher (since
> you can use regex in both).
Pattern just specifies a regular expression to search for. It is a
compiled form of the regular expression.
Matcher is the one that actually searches a particular sequence of
characters for the pattern and keeps track of where it was found, etc.
You don't really use a regex in both. You use a regex to create a
Pattern and you use a Pattern to create a Matcher.

Signature
Dale King