Reputation: 573
I need to get the interface indentification number of a VPN connection. So I use that command:
route print 256.* | find "The VPN Name"
This displays a line like that:
46..................The VPN Name
But I only want the digits at the begining. The number can be 1 to 3 digits long. How can I do that?
------------EDIT-----------
Partial solution:
for /f %%i in ('route print 256.* ^| find "The VPN Name"') do set GC_Line=%%i
echo %GC_Line:~0,3%
Upvotes: 0
Views: 95
Reputation: 61
Why not try (Powershell)
$string = route print 256.*
$regex_vpn= [regex] '.*The VPN Name'
$regex_no= [regex] '\d+(?=.)'
$match_vpn = $regex_vpn.Match($string)
$match_no = $regex_no.Match($match_vpn.Value)
$match_no.Value
Upvotes: 0
Reputation: 56189
just split by .
and space and take the first token:
for /f "delims=. " %%i in ('route print 256.* ^| find "The VPN Name"') do set GC_Line=%%i
Upvotes: 3