Here is the original source text:
gi0/1 1G-Fiber -- -- -- -- Down -- -- Access
gi0/2 1G-Fiber -- -- -- -- Down -- --
gi0/3 1G-Fiber -- -- -- -- Down -- --
gi0/4 1G-Fiber -- -- -- -- Down -- --
gi0/5 1G-Fiber -- -- -- -- Down -- --
gi0/0/1 1G-Fiber -- -- -- -- Down -- -- Access
gi0/0/2 1G-Fiber -- -- -- -- Down -- --
gi0/0/3 1G-Fiber -- -- -- -- Down -- --
gi0/0/4 1G-Fiber -- -- -- -- Down -- --
gi0/0/5 1G-Fiber -- -- -- -- Down -- --
The code snippet I am working on is as follows:
var re = /(([\w]{2})[\/\d]{1,})\s+([\w\-\.\s]+){1,}[\r\n]/ig;
while ( (MyArray = re.exec(text)) != null ){
// Here I intend to obtain an array with the following values (MyArray)
[0] [matched string]
[1] gi0/1 (gi0/0/1)
[2] gi
[3] 1G-Fiber
[4] --
[5] --
[6] --
[7] --
[8] Down
[9] --
[10] --
[11] Access (only for the 1st and 6th row)
// However, the current output in (MyArray) is not correct
[0] [matched string]
[1] gi0/1 (gi0/0/1)
[2] gi
[3] "s" OR "empty"
}
You can view an online example at
I would appreciate any assistance with this. Thank you!