How do I return a list of only the server names? In other words
everything up to but not including the “:”. I can read the file in and
can even split it at the “:” but can’t seem to figure out how to only
get server.corp.abc.com server2.corp.def.com server3.corp.xyz.net
This looks for the beginning of a line followed by whitespace followed
by characters, which are neither colons nor whitespace. The latter part
is then saved.
If you don’t like the strings being in subarrays, you can append “map
&:first”.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.