VMD-L Mailing List
From: Axel Kohlmeyer (akohlmey_at_cmm.chem.upenn.edu)
Date: Tue Sep 04 2007 - 09:12:58 CDT
- Next message: maria goranovic: "Rebuilding lipid from headgroup coordinates only using psfgen, some atoms put on origin"
- Previous message: Axel Kohlmeyer: "Re: advanced python console"
- In reply to: Θωμας Ευαγγελιδης: "regular expression in Tcl"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
On Tue, 4 Sep 2007, [iso-8859-7] Θωμας [iso-8859-7] Ευαγγελιδης wrote:
TE>
TE>
TE> Hi,
TE>
TE> I need to write a regexp in Tcl to implement a grep command that will match
TE> exactly a line of a pdb file. Specifically, given a resid "13", a segname "SOD"
TE> and a type "ION", I need to get this line from the pdb:
TE>
TE> ATOM 6856 SOD SOD I 10 15.803 8.833 -20.385 1.00 0.00 ION
TE>
TE>
TE> In perl I would write the following regexp:
TE> "^ATOM\ *[0-9]*\ *SOD\ *.*10\ *[\-\.0-9]*\ **[\-\.0-9]*\ **[\-\.0-9]*\
TE> **[\-\.0-9]*\ **[\-\.0-9]*\ *ION\ \ \ $"
TE>
TE> But in Tcl I get an error for each of the following "[0-9]", "*[\-\.0-9]*",
TE> "\ *".
TE>
TE> Can anybody propose a accurate regexp in Tcl please?
please consider the tcl quoting conventions and language constructs.
strings quoted with "" are subject to evaluation and square brackets
are a part of the tcl syntax []. literal strings in tcl have to be
bracketed with curly braces {}. alternately you have to escape
everything that will be expanded in "" context with a backslash.
check out:
http://www.tcl.tk/man/tcl8.5/tutorial/tcltutorial.html
cheers,
axel.
TE> Thanks,
TE> Thomas Evangelidis
TE>
TE>
-- ======================================================================= Axel Kohlmeyer akohlmey_at_cmm.chem.upenn.edu http://www.cmm.upenn.edu Center for Molecular Modeling -- University of Pennsylvania Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323 tel: 1-215-898-1582, fax: 1-215-573-6233, office-tel: 1-215-898-5425 ======================================================================= If you make something idiot-proof, the universe creates a better idiot.
- Next message: maria goranovic: "Rebuilding lipid from headgroup coordinates only using psfgen, some atoms put on origin"
- Previous message: Axel Kohlmeyer: "Re: advanced python console"
- In reply to: Θωμας Ευαγγελιδης: "regular expression in Tcl"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]