开发者

How do I fix this regular expression?

开发者 https://www.devze.com 2023-03-03 23:32 出处:网络
I have the string: CN=Help & Technical,CN=Users,DC=dave,DC=com And I want to strip out everything between the \'=\' and the \',\' in a set of groups. Basically Im using this...

I have the string:

CN=Help & Technical,CN=Users,DC=dave,DC=com

And I want to strip out everything between the '=' and the ',' in a set of groups. Basically Im using this...

=([\开发者_高级运维w-\s]*)

And it is only dragging back the following :

=help
=users
=dave

So you can see im not getting Help & Technical in the first group which is what I want. Is this possible can anybody help me with the regex I just cant work it out...


I haven't tested this, but =([^,]*) should work.


You just need to include the & sign in your regular expression here.

=([\w-\s&]*)

Note that this is pretty restrictive so far... no apostrophes, no numbers, and no other punctuation. You may want to consider whether any of that will show up and add them as appropriate.


This should work

=(.+),|\w

It should match everything after the = until a , or a enter

0

精彩评论

暂无评论...
验证码 换一张
取 消