Boost logo

Boost :

From: Boris Kolpackov (boris_at_[hidden])
Date: 2005-12-05 16:15:22


"John Maddock" <john_at_[hidden]> writes:

> The expression you're using can match a zero-length string, so after it's
> matched the ".cidl" suffix, it then finds a second match of zero-length
> immediately afterwards, hense the two copies of "E.idl" in the output
> string.

The original expression is "(\.(idl|cidl|cdl))?$". Doesn't '$' at the
end means that this expression by definition cannot match two things
in a single string (since a string has only one end)?

> I'm afraid this dark corner was/is under-documented in the docs, but the TR1
> text (with which this version is intended to conform) is quite clear that
> this is the required behaviour.

For what it's worth, perl on my box (5.8.7) also think there is only one
match. But I guess C++ TR1 is more authoritative when it comes to regular
expressions (sorry, couldn't resist sarcasm when it comes to Std C++).

> As a workaround, you could specify format_first_only in the format flags
> (assuming you're replacing the suffix on a single filename), or you could
> use an expression like:
>
> (.)(\\.(idl|cidl|cdl))?$

Following the logic above it will match all single letters in the string,
no? The following seems to work thought: "^(.+?)(\.(idl|cidl|cdl))?$"

Thanks for your help,
-boris


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk