Re: RegEx partial matching

From: Stanimir Stamenkov (s7an10_at_netscape.net)
Date: 11/12/04


Date: Fri, 12 Nov 2004 15:39:52 +0200


/Yamin/:

> There is a very simple solution to this.
> Just keep appending data to your main buffer, and do a simple pattern
> match. If you don't want your buffer to be too big, simply chop off
> any early data that you know cannot match the string.

How do I know which earlier data cannot match the regular
expression? (see bellow)

> Suppose the string you're trying to match is 10 character long.
> If you've read 20 characters already, and you have not found a full
> match, you can safely discard the lower 10 characters. Normally I
> like to be safe and just keep 3x the length of the pattern I'm looking
> for.

I want to match full featured regular expressions not just fixed
strings (as I've included in my example for simplicity). I can't
possibly determine the result length which would match some regular
expression as in:

opentag [.\n]* closetag

What would be the length of "[.\n]*" ?

The only reasonable solution is to use rexeg library which supports
streaming source as Adam (bilbo) has already proposed in another
message in this thread.

-- 
Stanimir


Relevant Pages

  • Re: Help with simple parsing in F95
    ... characters after any leading spaces. ... first line where 23 occurs as the first sequence of characters after ... character:: buffer ... Pattern found on line 7 ...
    (comp.lang.fortran)
  • Re: Help with simple parsing in F95
    ... No problems with the length of buffer: ... assume that no lines are longer than, say, 200 characters, and have ... characters there are in the pattern, ... SUBROUTINE scan ...
    (comp.lang.fortran)
  • Re: Search for a string backwards in a file.
    ... Read a number of characters into a buffer. ... If you don't find the pattern: ...
    (comp.lang.cpp)
  • Re: RegEx partial matching
    ... or file)...and you want to match a string where the string can span ... Just keep appending data to your main buffer, and do a simple pattern ... If you've read 20 characters already, and you have not found a full ...
    (comp.lang.java.programmer)
  • Re: Quiz time
    ... pattern, can you think of any Raga (ok any non-vakra Raga if you ... and have promptly backed out when asked to substantiate it. ... My contention is that in regular ... of scales, where this ratio sequence appears to be random, like Miyan ...
    (rec.music.indian.classical)