输入字符串是这样的:OU = TEST:This001。我们需要额外的“This001”。最好的C#。
最佳答案
关于什么 :
/OU=.*?:(.*)/
下面是它的工作原理:
OU= // Must contain OU=
. // Any character
* // Repeated but not mandatory
? // Ungreedy (lazy) (Don't try to match everything)
: // Match the colon
( // Start to capture a group
. // Any character
* // Repeated but not mandatory
) // End of the group
对于
/
,它们是定界符,用于知道正则表达式在何处开始和在何处结束(以及添加选项)。捕获的组将包含
This001
。,但是使用简单的
Substring()
会更快。 yourString.Substring(yourString.IndexOf(":")+1);
资源: