jakarta-oro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Davey - Sun UK Support Engineer <michael.da...@Sun.COM>
Subject m//g and pos
Date Tue, 19 Feb 2002 09:59:02 GMT
Hi,

I was thinking of extending ORO to support the /g
modifier and pos command.  /g does a global match
and can be written in user code.

pos returns the offset of the firsst character after
the last match (as endOffset() does).  This is where
the next m//g match will start.  pos can also be used
to change where the next m//g match will start.

For instance, the Perl snippet:

$grafitto = "fee fie foe foo";
while( $grafitto =~ m/e/g ) {
    print pos $grafitto, "\n";
}

Can be implemented in ORO as:

public void testPos() {
    String grafitto = "fee fie foe foo";
    int i = 0;
          
    while ( __perl.match( "m/e/", grafitto ) ) {
        i += __perl.endOffset( 0 );
        System.out.println( i );
        grafitto = __perl.postMatch();
    }
}

However, it might be nice to implement the m//g
and pos functionality in ORO itself.  Is this
worth doing?

Where would one make the changes, in Perl5Util or
in the underlying OROMatcher libraries?
(technically, either is possible).

-- 
Michael

--
To unsubscribe, e-mail:   <mailto:oro-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:oro-dev-help@jakarta.apache.org>


Mime
View raw message