I need a small parser (jquery) that knows if an input is URL:PORT format
Posted
by Johua
on Stack Overflow
See other posts from Stack Overflow
or by Johua
Published on 2010-05-06T09:06:25Z
Indexed on
2010/05/06
9:18 UTC
Read the original article
Hit count: 232
You have a user input string from a textbox for example var strInput = $("#txtBox").val();
strInput has some string now. I need to now if it is of this format: IP:PORT
Basically a user can input something like this: http://192.168.300.22:20000
1) Frist part (protocol): http:// always needs to be replaced by: https:// 2) Second part (everything until the ":" sign): 192.168.200.22 (or www.google.com) 3) Third part (port): everyhing after ":" (example: 9999, 100000)
I step): TAKE THE INPUT var strInput = $("#txtBox").val();
II) step): PARSE THE INPUT
III) results):
var strProtocol = "https//"; var strIP = parsedIP; var strPORT = parsedPORT;
So i need 2 know how to get the values (parsedIP and parsedPORT).
© Stack Overflow or respective owner