Hi all-
I'm trying to match character constants of the form:
&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?
I should also point out that the ungainly:
((?<=^)|(?<=\s))
seems to be necessary inside a language grammar as (?<=\s) alone doesn't work, although it does in the search dialog. It matches within a line, but not at the beginning of a line. It may be that this is only the case with begin/end matching, and not single lines...
Thanks! Charles
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 '
--Hans
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
On Mon, 01 Sep 2008 23:37:50 +0200, Hans-Jörg Bibiko wrote:
Maybe this could help: E.g. ("|\x{27}) for " or '
Hi Hans-
I appreciate this and your following message. For some reason, I thought hex codes were entered as \x27 and not the \x{27} as you suggest. They work fine now...
Thanks! Charles
On 02.09.2008, at 01:12, Charles Turner wrote:
On Mon, 01 Sep 2008 23:37:50 +0200, Hans-Jörg Bibiko wrote:
Maybe this could help: E.g. ("|\x{27}) for " or '
Hi Hans-
I appreciate this and your following message. For some reason, I thought hex codes were entered as \x27 and not the \x{27} as you suggest. They work fine now...
AFAIK TM uses internally the Oniguruma regexp engine with wide hex chars: \x{7HHHHHHH} wide hexadecimal char
see http://manual.macromates.com/en/regular_expressions#syntax_oniguruma
On 02.09.2008, at 03:01, Michael Sheets wrote:
For using ' and " in the property lists see:
http://manual.macromates.com/en/appendix#property_list_format
To be honest I've never read this. Thanks for pointing this out.
--Hans
On Tue, 02 Sep 2008 07:23:04 +0200, Hans-Jörg Bibiko wrote:
On 02.09.2008, at 03:01, Michael Sheets wrote:
For using ' and " in the property lists see:
http://manual.macromates.com/en/appendix#property_list_format
To be honest I've never read this. Thanks for pointing this out.
Yes, thanks Michael! Very helpful...
Charles
For using ' and " in the property lists see:
http://manual.macromates.com/en/appendix#property_list_format
It explains the format and escapes.