[TxMt] Re: Troubles matching " and ' in language grammar
Hans-Jörg Bibiko
bibiko at eva.mpg.de
Mon Sep 1 22:00:41 UTC 2008
On 01.09.2008, at 23:37, Hans-Jörg Bibiko wrote:
> On 01.09.2008, at 22:38, Charles Turner wrote:
>> Hi all-
>> &a &B &!
>> 'c' 'D' '!'
>> "e" "F" "@"
>> ^G ^h ^+
>>
>> within the match field of a language grammar.
>>
>> If I use the search dialog box, this regexp will work for characters
>> enclosed in single apostrophes:
>>
>> ((?<=^)|(?<=\s))(([&^]\S)|(\'\S\'))(?=\s)
>>
>> But it doesn't work when I get it into the match field, I suspect
>> because of the framing apostrophes, as in:
>>
>> { name = 'constant.character.forth';
>> match = '((?<=^)|(?<=\s))(([&^]\S)|(\'\S\'))(?=\s)';
>> },
>>
>> Any ideas about what I'm doing wrong, or how I can solve my trouble?
>
> Maybe this could help:
> E.g. ("|\x{27}) for " or '
>
> 27 is the hex code for a '
If there is no need to distinguish between e.g. quoted.double and
quoted.single in your language grammar you could use this for instance:
match = '("|\x{27})([[:alnum:]]+)\1';
will match 'STRING' or "STRING" but not "STRING'
\1 contains the match of the first regexp group ("|\x{27})
--Hans
More information about the textmate
mailing list