C# Regex Expression

Amos Xia, 2018-04-30 13:28:12

C#使用Regex类来进行正则处理, 来自System.Text.RegularExpressions

Regular Expression Engine

  • By calling the static methods of the Regex class, it will cach regular expressions, good performance for same regular expression
  • By instantiating a Regex object with regular expression, immutable object, won’t be cached.

Operation

Match

Search for matched substring follow regex express in Input data.

Use Match object to extract matched substring.

Use Match.Success to check if find matched substring.

Use Match.Groups for substring match capturing groups in regular expression pattern.

Replace

Replace all matched substring in input data.

Split

Split inpu data by matched substring following pattern into array.



知识共享许可协议
本作品采用知识共享署名 4.0 国际许可协议进行许可。


Copyright© 2018 s2u2m