1 | <head> |
---|
2 | <title>Wildcards</title> |
---|
3 | <!-- Changed by: Chris ISELIN, 27-Mar-1997 --> |
---|
4 | <!-- Changed by: Hans Grote, 31-Jul-2002 --> |
---|
5 | </head> |
---|
6 | |
---|
7 | <body bgcolor="#ffffff"> |
---|
8 | |
---|
9 | <center> |
---|
10 | EUROPEAN ORGANIZATION FOR NUCLEAR RESEARCH |
---|
11 | <IMG SRC="http://cern.ch/madx/icons/mx7_25.gif" align=right> |
---|
12 | <h2>Regular Expressions</h2> |
---|
13 | </center> |
---|
14 | |
---|
15 | Some commands allow selection of items via "regular expression" strings. |
---|
16 | Such a pattern string <b>must</b> be enclosed in single or double quotes. |
---|
17 | MAD-X follows regexp (Unix regular expression patterns) for matching. |
---|
18 | The following features are implemented: |
---|
19 | <p> |
---|
20 | A "search string" below is the string containing the pattern, a "target |
---|
21 | string" is the string being searched for a possible match with the pattern. |
---|
22 | <ul> |
---|
23 | <li>"^" at the start of the search string: |
---|
24 | Match following search string at the start of the target string; otherwise |
---|
25 | the search string can start anywhere in the target string. To search for a |
---|
26 | genuine "^" anywhere, use "\^". |
---|
27 | <li>"$" at the end of the search string: |
---|
28 | Match preceding search string at the end of the target string; otherwise |
---|
29 | the search string can end anywhere in the target string. To search for a |
---|
30 | genuine "$" anywhere, use "\$". |
---|
31 | <li>".": |
---|
32 | Stands for an arbitrary character; to search for a genuine ".", use "\." |
---|
33 | <li>"[xyz]": |
---|
34 | Stands for one character belonging to the string contained in brackets |
---|
35 | (example: "[abc]" means one of a, b, c). |
---|
36 | <li>"[a-ex-z]": |
---|
37 | Stands for ranges of characters |
---|
38 | (example: "[a-zA-Z]" means any letter). |
---|
39 | <li>"[^xyz]" (i.e. a "^" as first character in a square bracket): |
---|
40 | Stands for exclusion of all characters in the list, i.e. "[^a-z]" |
---|
41 | means "any character but a lower case letter". |
---|
42 | <li>"*": |
---|
43 | Allows zero or more repetitions of the preceding character, either specified |
---|
44 | directly, or from a list. |
---|
45 | (examples: "a*" means zero or more occurrences of "a", |
---|
46 | "[A-Z]*" means zero or more upper-case letters). |
---|
47 | <li>"backslash-c" (e.g. "\."): |
---|
48 | Removes the special meaning of character c. |
---|
49 | </ul> |
---|
50 | All other characters stand for themselves. |
---|
51 | Example: |
---|
52 | <pre> |
---|
53 | select,flag=twiss,pattern="^d..$" ; |
---|
54 | select,flag=twiss,pattern="^k.*qd.*\.r1$" ; |
---|
55 | </pre> |
---|
56 | The first command selects all elements whose names have exactly three |
---|
57 | characters and begin with the letter "D". |
---|
58 | The second command selects elements beginning with the letter "K", |
---|
59 | containing the string "QD", and ending with the string ".R1". |
---|
60 | The two occurrences of ".*" each stand for an arbitrary |
---|
61 | number (including zero) of any character, |
---|
62 | and the occurrence "\." stands for a literal period. |
---|
63 | <p> |
---|
64 | |
---|
65 | <address> |
---|
66 | <a href="http://www.cern.ch/Hans.Grote/hansg_sign.html">hansg</a>, |
---|
67 | May 8, 2001 |
---|
68 | </address> |
---|
69 | |
---|
70 | </body> |
---|