This section describes how to replace a character string on a device. This function supports batch replacement.
If a character string or a type of character string on a device does not meet requirements, perform the following steps to replace the string in batches. This function replaces only the character strings in the current view.
This function is supported only in the two-phase configuration validation mode.
The system view is displayed.
The source character string is replaced with the target character string.
The src-string parameter supports regular expressions. You can use a regular expression to specify a type of source character string.
Special Character |
Function |
Example |
---|---|---|
\ |
Defines an escape character, which is used to mark the next character (common or special) as a common character. |
\* matches *. |
^ |
Matches the start position of the string. |
^10 matches 10.10.10.1 not 2.2.2.2. |
$ |
Matches the end position of the string. |
1$ matches 10.10.10.1 not 10.10.10.2. |
* |
Matches the preceding element zero or more times. |
10* matches 1, 10, 100, 1000, and so on. (10)* matches null, 10, 1010, 101010, and so on. |
+ |
Matches the preceding element once or more times |
10+ matches 10, 100, 1000, and so on. (10)+ matches 10, 1010, 101010, and so on. |
? |
Matches the preceding element zero times or once. NOTE:
Huawei datacom devices do not support regular expressions with ?. When regular expressions with ? are entered on Huawei datacom devices, helpful information is provided. |
10? matches 1 or 10. (10)? matches null or 10. |
. |
Matches any single character. |
a.b matches any string that starts with a, ends with b, and contains three characters. 0.0 matches 0x0, 020, and so on. .oo matches book, look, tool, and so on. |
() |
Matches and obtains a string within the parentheses. If the parentheses are empty, the string is equivalent to a null string. If a pattern string has only (), it can match any string. If the right parenthesis in a pattern string has no matching left parenthesis, the right parenthesis is used as a common character. If the left parenthesis in a pattern string has no matching right parenthesis, the pattern string is invalid. |
100(200)+ matches 100200, 100200200, and so on. (ab) matches abcab. () can match any string. a()b matches 12ab12. a)b matches za)bc. a(b is an invalid pattern string. |
_ |
Matches regular expressions with a sign, such as a comma (,), left brace ({), right brace (}), left parenthesis ((), right parenthesis ()), or space. The underscore (_) can be used at the beginning of a regular expression with the same function as the caret (^) or at the end of a regular expression with the same function as the dollar sign ($). |
_65001_ matches 20 65001 30, 20 65001, 65001 30, 65001, and so on. |
x|y |
Matches x or y. |
100|200 matches 100 or 200. 1(2|3)4 matches 124 or 134 not 1234, 14, 1224, or 1334. |
[xyz] |
Matches any character in the regular expression. It cannot simultaneously match multiple characters or match the same character for multiple times. |
[123] matches 2 in 255. [abc] matches characters a, b, and c. |
[^xyz] |
Matches characters excluding x, y, and z in a character string. That is, it matches any string with at least one character that is not x, y, or z. |
[^123] matches any character except 1, 2, and 3. [^abc] matches any character except a, b, and c. |
[a-z] |
Matches any character within a specified range. It cannot simultaneously match multiple characters or match the same character for multiple times. |
[0-9] matches any character within the specified range. [a-z] matches any character within the specified range. [z-a] is an invalid pattern string. |
[^a-z] |
Matches characters except a, b, c, and d in a character string. That is, it matches any string with at least one character that is beyond the range of a to d. |
[^0-9] matches all non-digit characters. [^a-z] matches all non-letter characters. [^z-a] is an invalid pattern string. |
Unless otherwise specified, all characters in the preceding table are displayed on the screen.
Check whether the post-replacement configurations meet the expectation.
The configuration is committed.