Anchoring in a regex

2006-06-29 Thread Robert Hicks

syn match tclV "ttk\(\(::\)\?\([[:alnum:]_.]*::\)*\)\a[a-zA-Z0-9_.]*"

I only want this to work "ttk" at the start. I know that ^ means the 
start but I am not sure how to add that (I did try just adding it) to 
make the regex start with "ttk".


Robert



Re: Anchoring in a regex

2006-06-29 Thread Tim Chase

syn match tclV "ttk\(\(::\)\?\([[:alnum:]_.]*::\)*\)\a[a-zA-Z0-9_.]*"

I only want this to work "ttk" at the start. I know that ^ means the 
start but I am not sure how to add that (I did try just adding it) to 
make the regex start with "ttk".


Just put it at the beginning:

"^ttk..."

just as you would use the dollar-sign at the end to anchor 
something to the end of the line:


"regexp$"

-tim






Re: Anchoring in a regex

2006-07-14 Thread A.J.Mechelynck

Tim Chase wrote:

syn match tclV "ttk\(\(::\)\?\([[:alnum:]_.]*::\)*\)\a[a-zA-Z0-9_.]*"

I only want this to work "ttk" at the start. I know that ^ means the 
start but I am not sure how to add that (I did try just adding it) to 
make the regex start with "ttk".


Just put it at the beginning:

"^ttk..."

just as you would use the dollar-sign at the end to anchor something to 
the end of the line:


"regexp$"

-tim


Similarly, to allow it as long as it is the first non-whitespace 
characters, add "zero or more whitespace" between ^ and ttk :


"^\s*ttk..."

See ":help pattern.txt" for more info on Vim regular expressions (and 
dont forget the .txt extension, or you'll be brought to a formal syntax 
definition instead of to the table of contents of the helpfile).


Note that $^ in the middle of a pattern usually matches dollar followed 
by caret, not a linebreak. ( \n matches a linebreak IIUC; but in 
substitute you must use :s/\n/\r/ to replace a linebreak by itself.)



Best regards,
Tony.


Re: Anchoring in a regex

2006-07-17 Thread Robert Hicks

A.J.Mechelynck wrote:

Tim Chase wrote:

syn match tclV "ttk\(\(::\)\?\([[:alnum:]_.]*::\)*\)\a[a-zA-Z0-9_.]*"

I only want this to work "ttk" at the start. I know that ^ means the 
start but I am not sure how to add that (I did try just adding it) to 
make the regex start with "ttk".


Just put it at the beginning:

"^ttk..."

just as you would use the dollar-sign at the end to anchor something 
to the end of the line:


"regexp$"

-tim


Similarly, to allow it as long as it is the first non-whitespace 
characters, add "zero or more whitespace" between ^ and ttk :


"^\s*ttk..."

See ":help pattern.txt" for more info on Vim regular expressions (and 
dont forget the .txt extension, or you'll be brought to a formal syntax 
definition instead of to the table of contents of the helpfile).


Note that $^ in the middle of a pattern usually matches dollar followed 
by caret, not a linebreak. ( \n matches a linebreak IIUC; but in 
substitute you must use :s/\n/\r/ to replace a linebreak by itself.)



Thanks Tony and welcome back.  : )

I figured out that ttk:: can occur after a left "[" as in "[ttk::" and I 
am looking at the others as well.


Is there a way to do an "or" so that I can put ttk in {} [] "" and it be 
colored or is there a better way like a region?


:Robert