Selection of all atoms with a name starting with C:
Segment names containing a number:
Multiple terms can be provided on the list of matching keywords. This example selects residues starting with an A, the glycine residues, and residues ending with a T. As with a string, a regular expression in a numeric context gets converted to an integer, which will always be zero:
resname "A.*" GLY ".*T"
Selections containing special characters such as , ,
or , must be escaped with the
\ character. In order to select
Na+, one would use the selection:
In brief, a regular selection allows matching to multiple possibilities, instead of just one character. Table 6.9 shows some of the methods that can be used.
There are many ways to do some selections. For example, choosing atoms with a name of either CA or CB can be done in the following ways:
name CA CB name "CA|CB" name "C[AB]" name "C(A|B)"
Several caveats for those who already understand regular expressions.
VMD automatically prepends ``
^('' and appends
)$'' to the selection string. This makes the selection O match only O and not OG or PRO. On the other
$ into the command won't really
affect anything, selections that match on a substring must be
preceded and followed by ``.*'', as in
.*O.*, and some illegal
selections could be accepted as correct, but strange, as in
, which gets converted to
and matches anything starting with a C or ending with an O.
A regular expression is similar to wildcard matching in X-PLOR. Table 6.10 is a list of conversions from X-PLOR style wildcards to the matching regular expression.