Re: [ROOT] What features does TRegexp support?

From: Christian Holm Christensen (cholm@hehi03.nbi.dk)
Date: Thu Aug 08 2002 - 00:36:35 MEST


Hi David, 

On Wed, 07 Aug 2002 14:50:30 CDT
David Faden <dfaden@iastate.edu> wrote
concerning "[ROOT] What features does TRegexp support?":
> Hi,
>    What regular expression features does TRegexp have? The following 
> expression (taken from the perldata man page) doesn't seem to work:
> 
> ^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$

First off, you did remember to escape the backslashes, didn't you?

Second off, it has previously been mentioned [1] that TRegexp does not 
support all Perl extensions to the `normal' (Posix?) regular
expressions - I think Emacs Regular Expressions is a better reference
(start emacs, type "C-h i m emacs C-j m Regexps C-j").  

Thirdly, I'm not sure about the underlined:

  ^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$
          ^^^
          
What do you mean? Is it an optional '(' - in that case I think it
needs to be escaped, otherwise you have a syntax error.  Is it a Perl
operator? - in that case, I don't think it's valid.  

However, I do agree that some doc on the avaliable operators, ladida,
would be nice.  For example, is character classes supported: 
  
  root [0] TString n("1234")
  root [1] TRegexp re("[[:digit:]]+")
  root [2] int l   
  root [3] re.Index(n, &l)
  (const Ssiz_t)(-1)

Doesn't seem like it. 

There's a Perl compatible library called pcre (Perl Compatible Regular
Expressions), avaliable for many platforms at [2].  If you're on a
GNU/Linux box, chances are that you have it already.  A C++ wrapper
exists at [3] too. See also [4] 

Yours,

 ____ |  Christian Holm Christensen 
  |_| |	 -------------------------------------------------------------
    | |	 Address: Sankt Hansgade 23, 1. th.  Phone:  (+45) 35 35 96 91
     _|	          DK-2200 Copenhagen N       Cell:   (+45) 24 61 85 91
    _|	          Denmark                    Office: (+45) 353  25 305
 ____|	 Email:   cholm@nbi.dk               Web:    www.nbi.dk/~cholm
 | |



[1] http://root.cern.ch/root/roottalk/roottalk01/4536.html
[2] http://www.pcre.org/
[3] ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Contrib/
[4] http://www.daemon.de/pcre++/



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:03 MET