I a trying to come with a regex to create a standard UK mobile number. From what I have seen in the data set, the numbers come in the following different formats
+44 (0) 7111111111
+44 71111111111
44 71111111111
07111111111
NULL
What I am looking to do is have all of them start with 07, followed by 9 numbers e.g.
07111111111
So the first thing I need to do is remove all spaces
var origmob = "+44 (0) 1111111111";
newmOB = origmob.replace(/\s/g, "");
console.log(newmOB);
Next, I need to somehow match
+44(0)
OR
+44
OR
44
OR
0 //This one is correct, not sure if I need to check this
This is where I think I become a bit stuck. At the moment I have this
var origmob = "+44 (0) 1111111111";
newmOB = origmob.replace(/ /g, "").replace(/^(\+44\(0\)|(\+44)|(44))/g, "0");
console.log(newmOB);
It kind of works sometimes, but I do not think it is very good. It does not start the string with 07, and it does not check the length after this. It also does not replace NULL with an empty string.
How could I improve this mixture of regex and replace to format different numbers into the standard format I am after?
Thanks
NULLcheck a separate case.