On 08/21, Janek Schleicher said something like: > John W. Krahn wrote at Tue, 20 Aug 2002 22:43:55 +0200: > > > Shawn wrote: > > You can use \d instead of [0-9], \D instead of [^0-9] and \S instead of > > [^\s]. > > > > /^(\D+)(\d+ |)(\d+\/\S+)(.*)$/ > ^^^^^^^ > > That's still an ugly and slow way to have an optional match > better write it as > > m!^(\D+)(\d+ )?(\d+/\S+)(.*)$!
Much better. The list says beginners, but the intelligence and helpfulness is expert and professional. > What I still don't understand is why it's necessary to capture the rest in $4. > In the given examples > "Ethernet1/0", "T3 3/0/2", "POS2/0/1" > there is no rest. Off the top of my head, "FastEthernet0/0.10-802.1Q vLAN subif" > Could it also be that the first part is simply a name > that could have some digits at the end and > the second part is a path. > If the name ends on a digit, > then the name and the path are seperated with a blank. > I ask, as this job could be done quite easier: The path can have [\d/.:] and maybe more funcky junk. All I'm sure about is that a greedy match of non-whitespaces match it nicely. > m!^(\w+?) ?([\d/]+)$/ [untested] > > allthough I don't believe that this solution is quicker. -- Shawn Leas [EMAIL PROTECTED] My grandfather invented Cliff's Notes. It all started back in 1912... well, to make a long story short... -- Stephen Wright -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]