jakarta-oro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sharpe, Cassandra" <cassandra_sha...@merck.com>
Subject Using the Util.split() method
Date Fri, 31 May 2002 12:24:32 GMT

I am trying to split pipe delimited text using the Util.split() method.
However, instead of splitting the string based upon the pattern, it is
splitting the string along every character.  I included a code example
below.  When I split the pipe delimited string, I get 39 results.  When I
split the comma delimited string, I get 7 results, which is what I want.
Does anyone have any suggestions?

Thank You,

 import org.apache.oro.text.regex.*;
 import java.util.ArrayList;

public class TestSplit {

  private static String pipes = "E|1|1|abdomen|abdomen|abdomin|abdomin";
  private static String commas = "E,1,1,abdomen,abdomen,abdomin,abdomin";

  public TestSplit() {}

  public static void main( String[] args )throws Exception {

    ArrayList results = new ArrayList();

    Pattern commaPattern = null;
    Pattern pipePattern = null;

    PatternMatcher matcher = new Perl5Matcher();
    PatternCompiler compiler = new Perl5Compiler();

    pipePattern = compiler.compile("|");

    commaPattern = compiler.compile(",");

      Util.split(results, matcher, commaPattern, commas,  Util.SPLIT_ALL);
      System.out.println("Number with commas: " + results.size());


      Util.split(results, matcher, pipePattern, pipes,  Util.SPLIT_ALL);
      System.out.println("Number with pipes: " + results.size());

Notice:  This e-mail message, together with any attachments, contains information of Merck
& Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary
copyrighted and/or legally privileged, and is intended solely for the use of the individual
or entity named in this message.  If you are not the intended recipient, and have received
this message in error, please immediately return this by e-mail and then delete it.


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

View raw message