replace

xiaoxiao2021-03-06  20

.NET Framework routine reference

replace

Allow replacement only in the replacement mode. For similar features in regular expressions, use the backward reference (such as / 1). For more information on the backward reference, see the reverse reference and reverse reference construction.

Character escape and replacement is the only special constructor identified in the replacement mode. All grammar constructs described in the following sections are only allowed to appear in the regular expression; they do not recognize them in the replacement mode. For example, the replacement mode A * $ {txt} B is inserted into the string "a *", followed by the sub-string (if any), if any, if any), then follow the string "B". In the replacement mode, * characters will not be identified as metamatics. Similarly, the $ mode is not recognized in the regular expression matching mode. In the regular expression, the end of the specified string is specified.

The following table shows how to define a replacement mode named and numbered.

Character Description $ Number Replace the last sub-string that matches the number Number (decimal). $ {name} Replace the last sub-string of matching (? ). $$ Replace a single "$" character. $ & Replaces a copy of itself. $ `Replaces all the text of the input string before matching. $ 'Replaces all the text of the entered input string. $ Replaces the last captured group. $ _ Replace the entire input string.

See

Regular expression language elements

转载请注明原文地址:https://www.9cbs.com/read-42776.html

New Post(0)