Thanks.  Option two was better for me.  I didn't realize the 
BBLMKeywordPatterns were for 'words' only.  I struggled a bit with getting 
commenting to get highlighted.  I ultimately had to define a 'Comment Pattern' 
as well.  Something about the 'Keyword Pattern' prevented the 'Open Line 
Comment' from working, at least how I defined them.  The two patterns were:

<key>Keyword Pattern</key>
<string><![CDATA[(?x)
^[^#]\w+(?=:)
]]></string>

<key>Comment Pattern</key
<string><![CDATA[(?x)
^\# .* $
]]></string>

Tim

On Wed, Feb 16, 2022, at 7:02 AM, jj wrote:
> Hi Tim,
> 
> As far as I understand it, BBLMKeywordPatterns are matched against individual 
> words composed of characters in the <Identifier and Keyword Character Class> 
> or <Identifier and Keyword Characters>.
> 
> As a consequence the ^ anchor in a BBLMKeywordPatterns is sort of equivalent 
> to \b and will always match at the start of a word. 
> Start of line for an individual word doesn't make much sense.
> 
> (_Please Rich or Patrick, correct me if I am wrong_)
> 
> You could kind of achieve what you are looking for by including the '%' and 
> ':' characters in the <Identifier and Keyword Character Class> and matching 
> in the BBLMKeywordPatterns with:
> 
>     keyword: 
>     
> and 
> 
>     %keywordtwo:
>     
> Watch out though that those sequences might be present in some other unwanted 
> positions in the text, for example at the end of a line before a bullet list.
> 
> Another solution could be to use the <Keyword Pattern> which is matched 
> against the text of the document and thus can detect ^ anchors at the start 
> of lines.
> 
>     ...
>     <key>Language Features</key>
>     <dict>
>     ...
>     <key>Keyword Pattern</key>
>         <string><![CDATA[(?x)
> (
>     ^keyword(?=:)
> |
>     ^%keywordtwo(?=:)
> )
> ]]></string>
>     ...
>     <dict/>
>     ...
>     
> HTH
> 
> Jean Jourdain
> On Tuesday, February 15, 2022 at 4:44:59 PM UTC+1 Tim Gray wrote:
>> I have a question about defining keyword pattern matching in codeless 
>> language modules using BBLMKeywordPatterns. Can a pattern be defined to 
>> match only words at the beginning of a line? I’m not having much success 
>> using the standard ^ regular expression. 
>> 
>> To give context, I’d like to define two types of run kinds. Both are always 
>> at the beginning of a line and end with a colon; one also leads off with a 
>> %. Example: 
>> 
>> Keyword: do not match anything after the colon 
>> %keywordtwo: don’t match this either 
>> 
>> Thanks 
>> Tim 
>> 
>> 
> 
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a feature 
> request or need technical support, please email "[email protected]" 
> rather than posting here. Follow @bbedit on Twitter: 
> <https://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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/bbedit/89ea7013-1814-44f6-abde-3ef03aaeefa8n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/bbedit/89ea7013-1814-44f6-abde-3ef03aaeefa8n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://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 view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/cbd09313-95d9-42e9-8b89-234700cbadd0%40www.fastmail.com.

Reply via email to