Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4470527

RFE: \G anchor missing from java.util.regex.Pattern

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.4.0
    • core-libs
    • beta2
    • generic
    • generic



      Name: yyT116575 Date: 06/15/2001


      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)


      I am very happy to see regular experssions have finally turned up in JAVA but..
      The very useful at times "\G" achor has not been included as a boundary matcher.

      This is essential for tokenising where all characters in the string must be
      accounted for nd \\G is used to force the match to start when the previous
      match completed.

      import java.io.*;
      import java.net.*;
      import java.util.*;
      import java.util.regex.*;

      class p {
        public static void main ( String[] unused ) {
          Pattern p = Pattern.compile( "\\G\\w+\\w*" );
          Matcher m = p.matcher( "aab abbb cc" );

          while ( m.find() ) {
            System.out.println( m.group() );
          }
        }
      }
      (Review ID: 126697)
      ======================================================================

            mmcclosksunw Michael Mccloskey (Inactive)
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: