D
deepak_kamath_n
Hello,
I am relatively new to the world of regex and require some help in
forming a regular expression to achieve the following:
I have an input stream similar to:
Slot: slot1
Description: this is a description
Slot: slot2
Description: this is the second description
Attribute1: atrra
Attribute2: attrb
Slot: slot3
Description: this is the third description
Attribute1: atrrc
Attribute2: attrd
I have to pick all the values for "Slot" and corresponding
"Attribute2". If there is no "Attribute2" for a "Slot", I need to skip
that Slot.
I arrived at a regular exp similar to:
"^Slot:\\s+(.*?)\\s+Description:\\s+.*?\\s+Attribute1:\\s+.*?\\s+Attribute2:\\s+(.*?)\\s+.*?$"
but no luck. For the above example, this gives me "slot1 and attrd",
wheras I was expecting slot2, attrb and slot3, attrd.
Any thoughts on this is highly appreciated.
Thanks in advance!
Regards,
Deepak
I am relatively new to the world of regex and require some help in
forming a regular expression to achieve the following:
I have an input stream similar to:
Slot: slot1
Description: this is a description
Slot: slot2
Description: this is the second description
Attribute1: atrra
Attribute2: attrb
Slot: slot3
Description: this is the third description
Attribute1: atrrc
Attribute2: attrd
I have to pick all the values for "Slot" and corresponding
"Attribute2". If there is no "Attribute2" for a "Slot", I need to skip
that Slot.
I arrived at a regular exp similar to:
"^Slot:\\s+(.*?)\\s+Description:\\s+.*?\\s+Attribute1:\\s+.*?\\s+Attribute2:\\s+(.*?)\\s+.*?$"
but no luck. For the above example, this gives me "slot1 and attrd",
wheras I was expecting slot2, attrb and slot3, attrd.
Any thoughts on this is highly appreciated.
Thanks in advance!
Regards,
Deepak