Regexps

Amanda Clare ajc99@aber.ac.uk
Wed, 11 Jul 2001 16:00:20 +0100


Ken Shan wrote:
> 
> On 2001-07-11T15:41:28+0100, Amanda Clare wrote:
> >   let exp = mkRegex "^class\(\[(.*)\],"  in
> 
> I think you need to use two backslashes instead of one. 

Thanks, that's great, it works. However a simple match of this pattern
against "class([1,0,0,0],\"METABOLISM\")." gives me 

["1,0,0,0","","","","","","","","","","","","","","","","","","","","","","","","","","","",""]

ie the right answer, and 28 other empty answers. 

The documentation says

"Note that there may be more components in the returned list than were
in the pattern, and that any component which either matched the empty
string or wasn't matched at all (because it was part of an optional part
of the pattern), will be empty."

Does this mean I had 28 matches with the empty string? Why are they
returned? Will I always have to filter all these null strings out of
every result? Will the result I want always be first?

Amanda

--
Amanda Clare  http://users.aber.ac.uk/ajc99/
Tel: +44 (0)1970 621922  Fax: +44 (0)1970 622455
Dept. of Computer Science, University of Wales, Aberystwyth, SY23 3DB