TCL.regexp

Giorgos Keramidas keramida at ceid.upatras.gr
Sun Jun 4 09:17:52 EEST 2006


On 2006-06-03 23:16, Nikolaos Korkakakis <korkakak at gmail.com> wrote:
> kalhspera
>
> Xerei kaneis an uparxei dunatothta se ena regexp ths TCL na perasw san
> expression pros match kapoio string pou brisketai mesa se textvariable?
>
> kati san :
>
> regexp {$asdf ([0-9|\.])} match value
>
> To wish (alla kai to tclsh (8.4)) den griniazoun alla pairnoun to $asdf oxi san
> metablhth alla san literal ("$asdf")

To {...} quoting ftaiei.  Des p.x. to parakatw apotelesma:

    giorgos at gothmog:/home/giorgos$ tclsh8.4
    % package require http
    2.5.1
    % set url "http://www.slashdot.org/"
    http://www.slashdot.org/
    % set apache "Apache"
    Apache
    % set id [::http::geturl $url]
    ::http::1
    % set data [::http::data $id]
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <HTML><HEAD>
    <TITLE>301 Moved Permanently</TITLE>
    </HEAD><BODY>
    <H1>Moved Permanently</H1>
    The document has moved <A HREF="http://slashdot.org/">here</A>.<P>
    <HR>
    <ADDRESS>Apache/1.3.33 Server at www.slashdot.org Port 8080</ADDRESS>
    </BODY></HTML>

    % regexp "$apache" $data match
    1
    % puts "$match"
    Apache
    % exit

To $match string ontws periexei to meros tou $data pou ekane match.
Apla, anti gia {$apache} sto regexp perasa ws pattern to "$apache",
kai to $apache egine interpolate mesa sto match pattern.




More information about the Linux-greek-users mailing list