6.2.5 Regular expressionsString variables can be modified using the search-and-replace string operator1, = pyxplot> twister="seven silver soda syphons" Note that only the s (substitute) command of sed is implemented in Pyxplot. Any character can be used in place of the / characters in the above example, for example: twister =~ s's'th' Flags can be passed, as in sed or perl, to modify the precise behaviour of the regular expression. In the following example the g flag is used to perform a global search-and-replace of all instances of the letter s with the letters th: pyxplot> twister="seven silver soda syphons" Table 6.3 lists all of the regular expression flags recognised by the = g Replace all matches of the pattern; by default, only the first match is replaced. i Perform case-insensitive matching, such that expressions like [A-Z] will match lowercase letters, too. l Make m When specified, the pattern character s Make the . special character match any character at all, including a newline; without this flag, . will match anything except a newline. u Make x This flag allows the user to write regular expressions that look nicer. Whitespace within the pattern is ignored, except when in a character class or preceded by an un-escaped backslash. When a line contains a #, neither in a character class nor preceded by an un-escaped backslash, all characters from the left-most such # through to the end of the line are ignored. Table 6.3: A list of the flags accepted by the = ![]() Footnotes
|