如何使用c#从字符串中获取单引号单词



我的字符串看起来像

[Department] = 'Accounts' Or [Department] = 'HR'

我需要提取"(单引号)之间的字符串内容。即这里的预期输出是

账户HR-

我如何通过使用正则表达式来做到这一点。这里我列出了样本输入和输出

Input                                                             Output
[Department] = 'Accounts' Or [Department] = 'HR'                  Accounts, HR
[Department] In ('Accounts', 'HR', 'IT')                          Accounts, HR, IT
[Department] = 'IT'                                               IT

如果使用正则表达式很困难,我如何使用一些子字符串/拆分方法

'([^']*)'

这样就可以了。见演示。

http://regex101.com/r/bZ8aY1/3

最新更新