Hi,
why you dont use 2 split or 2 substr
ethernet t and pos are letter the rest is number
if you get the position of the last letter you just have to split the 
string, one for the string the rest for the details. That should be quicker.


Pierre


>From: Shawn <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Regex to split router ifDescr up
>Date: Tue, 20 Aug 2002 11:41:23 -0500
>
>So, I have an interesting question and a bit of code. I didn't really
>know whether this was the right forum or not, but here goes.
>
>I have two goals I would like help with:
>   1. Optimize/simplify the regex
>   2. Recognize where the regex would produce false positives on some
>      ifDescrs which don't actually have a real hardware path
>
>Really, #1 is most befitting this mailing list, but if anyone wants to
>help with #2 that's great.
>
>For those of you who are famimliar, a cisco router's SNMP ifDescr can
>contain what i would describe as the hardware path of whatever interface
>you are querying. For example, "Ethernet1/0", "T3 3/0/2", "POS2/0/1".
>Juniper routers have a similar thing.
>
>Now, I have the following regex to split these up into four pieces.
>/^([^0-9]+)([0-9]+ |)([0-9]+\/[^\s]+)(.*)$/
>         $1 : Is a required match of some non-numeric chars. This would
>              match "Ethernet", or the "T" in T3 or T1
>         $2 : An optional match which would catch the "3 " in ifDescrs
>              like "T3 3/0/1"
>         $3 : string starting with one or more numerics, then a "/", then
>              all non-whitespace
>         $4 : the rest
>
>In all cases I've seen, the text before the hardware path will only end
>in a numeric char if there is a space terminating it. Hence, "T3 3/0/2"
>returning $3 == "3/0/2" and "Ethernet0/1" returning $3 == "0/1".
>
>Now, can anyone see how the regex could be simplified?
>
>--
>Shawn Leas
>[EMAIL PROTECTED]
>
>Yesterday I parked my car in a tow-away zone... when I came back the
>entire area was missing...
>                                               -- Stephen Wright
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>




_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to