Hi Hasan,
I have a below string variable containing output of an EMC storage remote
command. The output looks like this:
*Director Identification: AB-1A*
Director Type : FiberChannel
Director Status : Online
Director Slot No : 4
Director Port: 5
WWN Port Name :331123G56
Director Port Status :PendOn
SCSI Flags
{
Sequence(SEQ) :Disabled
SCSI_Support1(OS2007) :Enabled
}
Director Port: 7
WWN Port Name :3323H66
Director Port Status :PendOn
SCSI Flags
{
Sequence(SEQ) :Disabled
SCSI_Support1(OS2007) :Enabled
}
*Director Identification: AB-1B*
Director Type : FiberChannel
Director Status : Online
Director Slot No : 6
Director Port: 33
WWN Port Name :331123G56
Director Port Status :PendOn
SCSI Flags
{
Sequence(SEQ) :Disabled
SCSI_Support1(OS2007) :Enabled
}
If you see here there are 2 loops :
1. One outer *Director Identification*
2. The each outer *Director Identification* has inner Director Port: loop
I need to extract outer and for each outer inner loops to process. Here is
what I am doing:
cmdoutput_nonewline = cmdoutput.gsub("\n",'|')
directorids = cmdoutput_nonewline.scan(/(?=(Director Identification.*?\|))/)
puts "#{directorids.size}"
directorids.each do |directorid|
puts directorid
end
This doesnot give required o/p, rather prints :
Director Identification: AB-1A|
Director Identification: AB-1B|
Regards,
Punit
On Wed, Jul 18, 2018 at 8:48 PM, Hassan Schroeder <
Post by Hassan SchroederPost by Punit JainI am working on an issue where i need to extract repeated text from an
The string is abcdefzfabcdefzfabcdefzf
I tried using forward lookup as /(?=(a.*f))/ but this extracts groups as
abcdefzfabcdefzfabcdefzf
abcdefzfabcdefzf
abcdefzf
abcdefzf
abcdefzf
abcdefzf
Can you explain what the logic of the pattern is? This "works" for
2.5.1 (main):0 > sample
=> "abcdefzfabcdefzfabcdefzf"
2.5.1 (main):0 > sample.scan /(?=(a.*?f.*?f))/
=> [
[0] [
[0] "abcdefzf"
],
[1] [
[0] "abcdefzf"
],
[2] [
[0] "abcdefzf"
]
]
2.5.1 (main):0 >
but might not be universally applicable...
--
Consulting Availability : Silicon Valley or remote
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>