Regex to match a string after colon

后端 未结 4 1816
长情又很酷
长情又很酷 2020-12-03 12:36

Input string is something like this: OU=TEST:This001. We need extra \"This001\". Best in C#.

4条回答
  •  春和景丽
    2020-12-03 13:18

    "OU=" smells like you're doing an Active Directory or LDAP search and responding to the results. While regex is a brilliant tool, I just wanted to make sure that you're also aware of the excellent System.DirectoryServices.Protocols classes that were made for parsing, filtering and manipulating just this sort of data.

    The SearchResult, SearchResultEntry and DirectoryAttribute in particular would be the friends you might be looking for. I don't doubt that you can regex or substring as cleverly as the next guy but it's also nice to have another good tool in the toolbox.

    Have you tried these classes?

提交回复
热议问题