Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Split IP-address

Status
Not open for further replies.

stevenfilip

Programmer
Feb 5, 2003
5
NL
Hi All,

For example I have an ip-address like : 192.168.1.1

I would like to put the first part of the ip-address in a
variable. So that I could output the number : 192

How would I do somehting like that?

Thanx!
 
Here is 3 different functions for you to look at...

<cfscript>
ipAddress = '123.456.789.012';

firstNumber = listFirst(ipAddress, '.');
secondNumber = listGetAt(ipAddress, 2, '.');
thirdNumber = listGetAt(ipAddress, 3, '.');
forthNumber = listLast(ipAddress, '.');
</cfscript>
------------------------------------------------------------------------------
brannonH
if( !succeed ) try( );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top