Hello! I'm pretty new to perl and trying to write a regex to match a sequence. Basically, I have a number of cells and for each cell, a number of pins. The pins are listed as :
Pin: U343.IN1 in
Pin: U713.INP out
The one with out at the end or with nothing at the end are the output pins that I want to match. So I got to:
/^[ ]+Pin:[ ]*([^\.]*)\.([^ ]*)$/
--> Matches " Pin: U714.QN"
$1 = U714
$2 = QN
/^[ ]+Pin:[ ]*([^\.]*)\.([^ ]*)[ ]out/
--> Matches " Pin: U713.INP out"
$1 = U713
$2 = INP
Is there a way to combine these two so that it matches both?
I tried using "|" to or them
^[ ]+Pin:[ ]*([^\.]*)\.([^ ]*)$|^[ ]+Pin:[ ]*([^\.]*)\.([^ ]*)[ ]out
But if the second part of the expression matches, my () come in under $3 and $4.
Basically, I want to match :
Pin: U713.INP"endofstring or out"
With $1 = U713
$2 = INP
I'm sure there's some simple way to do this and im over complicating it but I cant figure it out for the life of me. A nudge in the rigth dorection would be greatly appreciated. Thanks!