TRegexp optional expression?

Hi all,

as far as I understood one can use the parantheses and “?” for a TRegexp to declare an optional group of a string. So I thought if I write:

TRegexp exp("[0-9]+(-B)?")

this would mean that a pattern in a string is matched like: 098656348… but also: 0786123…-B, as “-B” should be optional. But it doesn"t work, what am I doing wrong? Thank you in advance!

Cheers - Daniel

Hi Daniel

TRegexp is rather limited and does not know about ( ). Try TPRegexp instead (the perl compatible regular expression).


Thank you very much! I didn"t know that one, it works now :slight_smile:

Cheers - Daniel


There is a tutorial for TPRegexp in tutorials/regexp.C