EUROPEAN ORGANIZATION FOR NUCLEAR RESEARCH

Regular Expressions

Some commands allow selection of items via "regular expression" strings. Such a pattern string must be enclosed in single or double quotes. MAD-X follows regexp (Unix regular expression patterns) for matching. The following features are implemented:

A "search string" below is the string containing the pattern, a "target string" is the string being searched for a possible match with the pattern.

All other characters stand for themselves. Example:
select,flag=twiss,pattern="^d..$" ;
select,flag=twiss,pattern="^k.*qd.*\.r1$" ;
The first command selects all elements whose names have exactly three characters and begin with the letter "D". The second command selects elements beginning with the letter "K", containing the string "QD", and ending with the string ".R1". The two occurrences of ".*" each stand for an arbitrary number (including zero) of any character, and the occurrence "\." stands for a literal period.

hansg, May 8, 2001