const regex = /.*\s(\d{11}|\d{5}\s\d{3}\s\d{3}|\d{5}\s\d{6}|\d{14}|\+\d{12}|\+\d{3}\s\d{3}\s\d{3}\s\d{3}|\d{4}\s\d{3}\s\d{3})\s.*/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('.*\\s(\\d{11}|\\d{5}\\s\\d{3}\\s\\d{3}|\\d{5}\\s\\d{6}|\\d{14}|\\+\\d{12}|\\+\\d{3}\\s\\d{3}\\s\\d{3}\\s\\d{3}|\\d{4}\\s\\d{3}\\s\\d{3})\\s.*', 'gm')
const str = `fdsgf dsgfd ggfs s 07123452670 ar gs fgsdf gsdf
t hth rt hrth rth 07812 345 931 tr yrt rty
try erty tr ytr y 07412 123466 tr yert y
tery ert y 00447912345188 etry ert y
tery etr yrt yret +971557017442 ert yert yrety
et yetr yertytr ety ert y +971 557 856 832 etry rt ytr y
etr yerty etry erty 0414 934 993 erty etry etry`;
const subst = `$1`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', result);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions