For Programmers: Free Programming Magazines  


Home > Archive > Tcl > October 2006 > Problem match begin of work with regexp









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Problem match begin of work with regexp
Steve Jenkins

2006-10-21, 7:03 pm

I am having a problem matching the beginning of words using regexp, at
least it is not working as I expect. Here is an example:

% set a {this is a test thathb}
this is a test thathb
% regexp -inline -all {\mth[a-z]} $a
thi tha thb

I would have expected only "thi" and "tha" to be returned as "thb" is
part of "thathb" and not at the beginning of the word. When I do the
following command, I get what I expect (but then the \m is not actually
necessary):

% regexp -inline -all {\mth[a-z]*} $a
this thathb

However, if I do the following command, it does work as I expect (note
there is only one "th" at the end, not two):

% regexp -inline -all {\mt[a-z]} $a
th te th

In place of "\m" I have also tried [[:<:]] with the same results. Looks
like something is disabling the \m function in the first command above.

What am I missing? (Oh, and I am using ActiveTcl 8.4.13.0 on Windows.)
Donald Arseneau

2006-10-21, 7:03 pm

Steve Jenkins <no_limits916@yahoo.com> writes:

> % set a {this is a test thathb}
> % regexp -inline -all {\mth[a-z]} $a
> thi tha thb


Looks like a bug to me.


--
Donald Arseneau asnd@triumf.ca
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com