M
Marc Girod
Hello,
I intend to start fixing an issue I have with a regexp of mine, but I
thought I might ask for comments even before I start myself.
I wanted to catch the text between '%[' ... ']N?l' brackets in a
'format specification' [*].
My first attempt worked well at first, with format strings such as
'%Vn %[^O13]Nl\n':
$fmt =~ s/\%\[(.*?)\](N?)l/$ph/
The text I catch is itself a regexp, but which I process in isolation
[I extend the format specification, so that '^O13' will be used as a
filter.]
Unfortunately, later, I started to use bolder format strings, such as
e.g.:
'%Vn %[Foo]NSa %[^O13]Nl\n'
My first regexp obviously bled over the two sets of brackets...
A first naive fix was:
$fmt =~ s/\%\[([^\]]*?)\](N?)l/$ph/
However, I can forsee that this prevents other valid specs, such as
e.g.:
'%Vn %[^[OE]]Nl\n'
I can also see that my strategy works only with *one* such field, but
I am willing to accept that, if I can support complex regexps inside
it.
The question I have is: am I doomed to implement a parser?
Or can I find a reasonable way out e.g. with look ahead?
Of course, I'll post what I get to myself, if I do (I won't jump to it
right away...)
Thanks!
Marc
*: I give the link to the man page for this, but I don't expect you to
need to read it:
<http://publib.boulder.ibm.com/infocenter/cchelp/v7r0m1/topic/
com.ibm.rational.clearcase.cc_ref.doc/topics/fmt_ccase.htm>
I intend to start fixing an issue I have with a regexp of mine, but I
thought I might ask for comments even before I start myself.
I wanted to catch the text between '%[' ... ']N?l' brackets in a
'format specification' [*].
My first attempt worked well at first, with format strings such as
'%Vn %[^O13]Nl\n':
$fmt =~ s/\%\[(.*?)\](N?)l/$ph/
The text I catch is itself a regexp, but which I process in isolation
[I extend the format specification, so that '^O13' will be used as a
filter.]
Unfortunately, later, I started to use bolder format strings, such as
e.g.:
'%Vn %[Foo]NSa %[^O13]Nl\n'
My first regexp obviously bled over the two sets of brackets...
A first naive fix was:
$fmt =~ s/\%\[([^\]]*?)\](N?)l/$ph/
However, I can forsee that this prevents other valid specs, such as
e.g.:
'%Vn %[^[OE]]Nl\n'
I can also see that my strategy works only with *one* such field, but
I am willing to accept that, if I can support complex regexps inside
it.
The question I have is: am I doomed to implement a parser?
Or can I find a reasonable way out e.g. with look ahead?
Of course, I'll post what I get to myself, if I do (I won't jump to it
right away...)
Thanks!
Marc
*: I give the link to the man page for this, but I don't expect you to
need to read it:
<http://publib.boulder.ibm.com/infocenter/cchelp/v7r0m1/topic/
com.ibm.rational.clearcase.cc_ref.doc/topics/fmt_ccase.htm>