freelanceprogrammers.org Forum Index » Perl
Re: string help
Joined: 03 May 2004
Posts: 8
Re: string help
Of course this is impossible to answer without knowing
the *general* syntax of all possible strings to match.
For your case, the following would work (code not tested!):
if
(/([0-9a-f]{2})([0-9a-f]{2}).([0-9a-f]{2})([0-9a-f]{2}).([0-9a-f]{2})(
[0-9a-f]{2})s+.*s+([A-Za-z]*d+/d+/d+)/)
Ronald
> here`s the input:
> 300 0000.0c07.ac02 DYNAMIC Gi1/0/12
>
> here`s the code:
> if (/([0-9a-f]{2})([0-9a-f]{2}).([0-9a-f]{2})([0-9a-f]{2}).([0-9a-
> f]
> {2})([0-9a-f]{2})s+.*(d+/d+/d+)/)
> {
> $hostmac = $1 . "-" . $2 . "-" . $3 . "-" . $4 . "-" . $5 . "-
> " . $6;
> $hostport = $7;
> print "mac: $hostmac, port: $hostport
";
> }
>
> here`s the actual output:
> mac: 00-00-0c-07-ac-02, port: 1/0/12
>
> here`s the desired output:
> mac: 00-00-0c-07-ac-02, port: Gi1/0/12
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







