Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
158
rated 0 times [  163] [ 5]  / answers: 1 / hits: 19868  / 9 Years ago, mon, september 21, 2015, 12:00:00
 var r = bd{1,3}.d{1,3}.d{1,3}.d{1,3}b; //http://www.regular-expressions.info/examples.html

var a = http://www.example.com/landing.aspx?referrer=10.11.12.13;

var t = a.match(r); //Expecting the ip address as a result but gets null


The above is my code to extract ip address from a string.
But it fails to do so.
Kindly advice where it fails.


More From » jquery

 Answers
3

You have defined r as string, initialize it as regular expression.


var r = /bd{1,3}.d{1,3}.d{1,3}.d{1,3}b/;



var r = /bd{1,3}.d{1,3}.d{1,3}.d{1,3}b/; //http://www.regular-expressions.info/examples.html

var a = http://www.example.com/landing.aspx?referrer=10.11.12.13;

var t = a.match(r);
console.log(t[0])




[#64987] Friday, September 18, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
karivictoriab

Total Points: 530
Total Questions: 90
Total Answers: 95

Location: Honduras
Member since Sun, Dec 26, 2021
2 Years ago
;