Hmm... although I have extensive documentation on the overall function 
(which I wrote quite a few years ago), I didn't document the regexp in 
detail. My notes (which are obviously ancient, based on the browsers 
mentioned) refer to the various ways that different browsers report 
transparency, such as "transparent" -or- "rgba(0, 0, 0, 0)" -or- other 
variations... let me now quote my old notes verbatim:

BUT would all CSS3 engines format the transparency string precisely that 
way? I’m pretty sure they’d start with “rgba” and end with “,0) or maybe “, 
0 )”, but I’m not so sure about what might come in between. It might be 
safer to use a regexp something like:     

    var css3Transp=    /^rgba.*,\s?0\s?\)$/i
    
or maybe combine the two possible formulations of ‘transparent’ (the 
traditional form and the CSS3 form) into:    
    
    var noCol    =    /^transparent|rgba.*,\s?0\s?\)$/i

[Back to the present]  Yes, I'm not entirely sure why the regexp was 
written like that, and I should have documented it more carefully... but it 
seems to work, even in modern browsers.

- - - - previous posts: - - - -
On Tuesday, January 20, 2015 at 6:52:42 PM UTC-5, Ronald J Kimball wrote:
>
> On Sun, Jan 18, 2015 at 06:12:21PM -0800, San wrote: 
> > Thanks, I'm sure you're right. I should have seen that. 
> > 
> > On the broader question of whether I need to "fix" this at all... does 
> the 
> > fact that a function doesn't balance in BBEdit imply that the function 
> is 
> > brittle, i.e. might throw an error under some circumstances, even though 
> > I'm not seeing any errors? 
>
> It actually implies that the Balance Tags feature is brittle.  It has to 
> deal with double-quoted strings, single-quoted strings, regular 
> expressions, comments, and so on, and sometimes it gets it wrong. 
>
> An alternative way to resolve this is to use "\x29" instead of "\)" in the 
> regular expression, as \x29 is the hexadecimal escape sequence for a right 
> parenthesis: 
>
> /^transparent|rgba.*,\s?0\s?\x29$/i 
>
>
> By the way, I'm concerned about the structure of this regular expression. 
> It matches either: 
>
> 1) "transparent" at the start of the string; or 
> 2) "rgba", followed by any number of characters, then ",", an optional 
>    whitespace character, "0", an optional whitespace character, and ")", 
> at 
>    the end of the string. 
>
> For example, it would match both of these strings: 
>
> "transparent blah blah blah" 
> "blah blah blah rgba blah blah blah, 0 )" 
>
> Is that really what is intended? 
>
> Ronald 
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].

Reply via email to