Hi there, Can someone please tell me how I can copy an IP Address to the clipboard then have a script split it into variables?
So:
192.168.2.4
Becomes:
$a = 192
$b = 168
$c = 2
$d = 4
I'm pretty sure I need regexreplace but I don't know how to get the separate sections of the IP Address. Cheers.
Split IP Address into variables
-
kiwichick
- Posts: 676
- Joined: 08 Aug 2012 04:14
- Location: Windows 10 Pro 22H2, 150% scaling
Split IP Address into variables
Windows 10 Pro 22H2
-
highend
- Posts: 14956
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Split IP Address into variables
What exactly do you want to do with these 4 single values afterwards?
There are many ways to get them into variables / do anything with them...
One possibility (assuming you've pasted an ip address to the clipboard before):
Depending on what you really want to do, regexmatches() is also a possible alternative.
There are many ways to get them into variables / do anything with them...
One possibility (assuming you've pasted an ip address to the clipboard before):
Code: Select all
$cb = "<clipboard>";
$a = gettoken($cb, 1, ".");
$b = gettoken($cb, 2, ".");
$c = gettoken($cb, 3, ".");
$d = gettoken($cb, 4, ".");One of my scripts helped you out? Please donate via Paypal
-
kiwichick
- Posts: 676
- Joined: 08 Aug 2012 04:14
- Location: Windows 10 Pro 22H2, 150% scaling
Re: Split IP Address into variables
Thank you so much highend!! I never would have got there!!
Windows 10 Pro 22H2
XYplorer Beta Club