Am 28.10.2010 um 28, 06:56 schrieb Ronald J Kimball:
> On Wed, Oct 27, 2010 at 08:58:37PM -0700, Govinda wrote:
>> Hi everyone
>> I am trying to make a grep search string which finds any HTML comment
>> that has a double hyphen inside itself.
>> 
>> It should find any HTML comment which:
>> - starts with "<!--",
>> - ends with "-->",
>> - spans any number of lines,
>> - contains two consecutive hyphen chars which are not part of the
>> opening "<!--" or closing "-->".
>> 
>> It should NOT match across multiple HTML comments.

> This will find HTML comments that contain exactly one occurence of -- in the
> middle of the comment and strip it out:
> 
> Find
> (?s)(<!--(?>(?:(?!--).)*))--(?!>)((?>(?:(?!--).)*)-->)
> 
> Replace
> \1\2

Nice problem. And nice solution by Ronald. This is how I would have done it:

search
(?s)(<!--[^-]*?)-+([^-]*?-->)
replace
\1\2

enjoy
Roland (oh, that name is also a variation of Ronald :-)


-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
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>

Reply via email to