Hi;
Here is my line of code that I need help in:
result_of_na_citrix=net group na-citrix /dom
.split(" ")
This gets all the users in in it’s own index split on a space.
However, there is a bunch of garbage (stuff that I do not need to
capture) before the names of the users are listed. Here is an example
The request will be processed at a domain controller for domain
abc.com.
Group name NA-CITRIX
Comment Owner:John D.
Members
The list of users begins here.
I need to get the list of users ONLY. Basically, to capture info AFTER
the dashes -----------. I did a 20.times do, but each group has a
different information. The ONLY consistent thing is the list of users
that start AFTER the dashes,
On 1/17/07, anon1m0us [email protected] wrote:
If I understand your question, something like this should help.
str = “Group name NA-CITRIX\nComment Owner:John
Doe\nMembers\n” +
“-----------------------------------------------------” +
“--------------------------\nThe list of users begins here.”
str =~ /.?-{3,}.?(\w.*)/m
puts $1
Look into regular expressions and adjust as necessary.
http://www.rubycentral.com/book/tut_stdtypes.html#S4
Harry
–
http://www.kakueki.com/ruby/list.html
Japanese Ruby List Subjects in English
anon1m0us wrote:
I need to get the list of users ONLY. Basically, to capture info AFTER
the dashes -----------. I did a 20.times do, but each group has a
different information. The ONLY consistent thing is the list of users
that start AFTER the dashes,
Use the String#[] method with a regex to just return the portion
following
the dashes, and split that:
result_of_na_citrix = net group na-citrix /dom
[/-+\n(.*)/m,1].split(" ")
cheers,
andrew
On Apr 5, 12:33 pm, Andrew J. [email protected] wrote:
result_of_na_citrix = net group na-citrix /dom
[/-+\n(.*)/m,1].split(" ")
cheers,
andrew
–
Posted viahttp://www.ruby-forum.com/.
I’d suggest:
separator =
“-------------------------------------------------------------------------------
\n”
junk,users = net group na-citrix /dom
.split(separator)
user_array = users.split(’ ')
YMMV
Cheers
Chris