Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2008-02-27 05:27:50


office_at_[hidden] wrote:
> [fg:red] [bg:white]
>
> is also a valid expression.
>
> The terms for color selection are partly optional, so valid
> expressions are
>
> [fg:red]
> or
> [bg:white]
> or
> [fg:red][bg:white]
> or
> [bg:white][fg:red]
>
> The key words for foreground and background colors are predefined by
> the software (red, green, blue, transparent, none, ...).

For the fg/bg part you could try something like:

"(?:\\[(?:fg|bg):(?:BLUE|RED|GREEN|BLACK|YELLOW|WHITE|CYAN|NONE)\\]){1,2}"

But that would then allow things like:

[bg:red][bg:white]

Which may not be what you want :-(

How about something like:

"(?:\\[(?(1)(?!\\1)))(fg|bg):(?:BLUE|RED|GREEN|BLACK|YELLOW|WHITE|CYAN|NONE)\\]){1,2}"

Which says: "if $1 is matched - the (fg|bg) part - then check a forward
lookahead assert that what follows is not the same as $1". But that only
works for *two* alternatives, and I haven't tried this out in code yet
either !

HTH, John.

>
> I tried starting with a pattern like (C++ syntax for strings)
>
> ^(?:(<|<=|>|>=|=|<>){1}((?:-|\\+)?[0-9]+(?:\\.[0-9]+|\\,[0-9]+)?))?(?:\\s*)(?:(\\[FG:(?:BLUE|RED|GREEN|BLACK|YELLOW|WHITE|CYAN|NONE)\\])|(\\[BG:(?:BLUE|RED|GREEN|BLACK|YELLOW|WHITE|CYAN)\\])|(\\[FG:(?:BBLUE|RED|GREEN|BLACK|YELLOW|WHITE|CYAN|NONE)\\])(?:\\s*)(\\[BG:(?:BLUE|RED|GREEN|BLACK|YELLOW|WHITE|CYAN)\\])){1}$
>
> But this does not allow the [fg:][bg:] terms to be interchanged and
> also when a new color or style will be added to the format class I
> have to change the pattern three times. I tried backward references
> with no success.
>
> So any help is very welcome
>
> Thanks in advance
>
> Martin
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net