anon1m0us wrote:> I am trying to capture a users group. I use dsquery and the output is
> a bunch of groups starting with the words CN= group name followed by
> a comma.
> I need the group name from after CN= and before the FIRST comma. How
> can i do it. I tried spilts, scans, and matches with out much success.
You didn''t give a complete example of what is returned by dsquery so
I''m
going to have take a guess at a working single regular expression match:
group_name = dsquery_str.gsub(/^CN=(.*?),.*$/, ''\1'')
If the ".*?" pattern is not working correctly you can do it the long
way
like this:
values = dsquery_str.split(/,/)
group_name = values[0].gsub(/^CN=(.*)/, ''\1'')
That will remove any confusion the commas can cause in the pattern matching.
--
Michael Wang
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---