You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oro-user@jakarta.apache.org by Troy Gould <tr...@dooyoo.co.uk> on 2001/11/07 13:05:42 UTC

wierd happening in split method

I'm trying to use the split method of the Perl5Util class.

I have a string:  (attrib.90 = 70 OR attrib17 RANGE (15, 20))

which I want to split on whitespace, open parenthesis and close
parenthesis.  I also want to include open and close parenthesis in my
Collection.

I'm using as my pattern,  "/ \s+ | ( [ ) ( ]/"    I've put the spaces in
for clarity in reading.  Also, I do include in the actual pattern the
escape code for the backslash.

I'm getting an odd behavior with the result.

I've printed the results with ** before the actual value and ** after.

**attrib.17** 
**=** 
**90** 
**AND** 
**** 
**(** 
**attrib.90** 
**=** 
**70** 
**OR** 
**attrib17** 
**RANGE** 
**** 
**(** 
**15,** 
**20** 
**)** 
**** 
**)** 
****

For some reason there is always an element created before an open
parenthesis and an element created after a close parenthesis.  Not sure
why that is happening and any help would be appriciated.

Also, is there a way to use the substitute method or some other perl
method to remove all whitespace from a String?  I'm not sure what the
pattern would be.  I tried "/\\s+//g", but just get a pattern exception.

Thanks for any help.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>