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 http://www.google.com)
3) Third part (port): everyhing after “:” (example: 9999, 100000)
-
I : TAKE THE INPUT
var strInput = $("#txtBox").val(); -
II : 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).
You can use regex for this. Pattern: