programming.nbk: Home | Index | Next Page: Tcl: Regular Expressions | Previous Page: Tcl: regexp ?switches? expression string ?matchvar submatchvar ...?
Tcl: regsub ?switches? expression string substitution_spec result_variable_name
Regular expression substitution procedure.
The results of the substitution is copied to result_variable_name if it
is given, or returns by the results.
Tcl: Regular Expressions
- ?switches? optional switches to modify the behaviour.
- expression is the regular expression to be searched for.
- string is the string to be searched.
- substitution_spec is an optional variable to receive the total part of string
that matched expression.
- result_variable_name optional variable to receive the results of
the substitution.
Optional Switches:
- -all
All ranges in string that match exp are found and substitution is performed for each of these ranges. Without this switch only the first matching range is found and substituted. If -all is specified, then ``& and ``\n sequences are handled for each substitution using the information from the corresponding match.
- -expanded
Enables use of the expanded regular expression syntax where whitespace and comments are ignored. This is the same as specifying the (?x) embedded option (see the re_syntax manual page).
- -line
Enables newline-sensitive matching. By default, newline is a completely ordinary character with no special meaning. With this flag, `[^' bracket expressions and `.' never match newline, `^' matches an empty string after any newline in addition to its normal function, and `$' matches an empty string before any newline in addition to its normal function. This flag is equivalent to specifying both -linestop and -lineanchor, or the (?n) embedded option (see the re_syntax manual page).
- -linestop
Changes the behavior of `[^' bracket expressions and `.' so that they stop at newlines. This is the same as specifying the (?p) embedded option (see the re_syntax manual page).
- -lineanchor
Changes the behavior of `^' and `$' (the ``anchors) so they match the beginning and end of a line respectively. This is the same as specifying the (?w) embedded option (see the re_syntax manual page).
- -nocase
Upper-case characters in string will be converted to lower-case before matching against exp; however, substitutions specified by subSpec use the original unconverted form of string.
- -start index
Specifies a character index offset into the string to start matching the regular expression at. When using this switch, `^' will not match the beginning of the line, and \A will still match the start of the string at index. index will be constrained to the bounds of the input string.
- - -
Marks the end of switches. The argument following this one will be treated as exp even if it starts with a -.
programming.nbk: Home | Index | Next Page: Tcl: Regular Expressions | Previous Page: Tcl: regexp ?switches? expression string ?matchvar submatchvar ...?
Notebook exported on Monday, 7 July 2008, 18:56:06 PM Eastern Daylight Time