[plug] [Somewhat OT] Regexp guru?

Kirk Turner mlist at wagoonline.com
Wed Dec 18 12:10:30 WST 2002


Thanks Tony,

Java regexp seems to match the perl implementation, however the split 
function works differently, in that it
doesn't return the tokens that you split upon (thus no having to grep 
out the empty strings).  So its now a case of convincing Java to give me 
the tokens... but thats given me enough to work with!

Thanks
Kirk

Anthony J. Breeds-Taurima wrote:

>On Tue, 17 Dec 2002, Kirk Turner wrote:
>
>  
>
>>Heyas,
>>
>>This isn't strictly a linux thing, but figured since regexp is used 
>>widely in linux someone might have more of a clue
>>than I do :-)
>>    
>>
>
><snip>
>
>Don't use Java so I don't know how good the re support is.  Howvere in perl
>
>---
>#!/usr/bin/perl -wT
>
>use strict;
>
>my $string= 'this is just a "simple little" test';
>my @strings = grep {!/^$/} split(/(\".*\"|[^\s]*)\s/,$string);
>
>print join("\n", at strings),$/;
>---
>
>should do what you want.
>
>Yours Tony
>
>   Jan 22-25 2003           Linux.Conf.AU            http://linux.conf.au/
>		  The Australian Linux Technical Conference!
>
>
>  
>




More information about the plug mailing list