syntax of regexp

Philip Greenspun's Homepage : Philip Greenspun's Homepage Discussion Forums : 6916 : One Thread
Notify me of new responses
hi. i have looked into the sources that are suggested to know more
about resexp in Tcl. still, in ex 3, i am getting no where. to solve
the problem of a 3-name entry i ended up to consider:
if {[regexp {(.*) (.* )+(.*)$} $full_name match first_name middle_name
last_name]} {

however this does not work with 2 names, and from what i understood
from studying the syntax, it would be be necessary to have the second
subpattern as (.*)* to code none or a sequence of characters followed
by a space. i tryed parenthesis to define but it did not work, and a
zillion more possibilities of syntax. can someone help me with this,
it seems that being focused on this by days it is too much for such a
simple problem, i mean with this that maybe i am not looking at it and
the syntax from the right view, so i have not been able to solve this.
is my interpretation of the syntax wrong?

ines

-- Ines Sousa, September 20, 1999

Answers

The example given for regexp in the original problem set should be easy enough to expand to handle the simple 3 and 4 name cases. You should expand upon this simple matching. The final pattern allows one or more spaces between matched patterns. It should also be noted that the final regexp here is not a final solution ... but may put you on the right track. If you have not already read the Tcl for Web Nerds Pattern Matching section.

-- Brian Stein, September 20, 1999