1578 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

Hi friends,

I am using javasrcript for string replacement,

i m currently doing replace.(string,tothisstring)

i have a regex for valid north American phone number here it is:
var regex = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;

its check valid phone number like (800)123 1234, 800.123.1456 etc etc formats.

i want to replace (800)123 1234 to (800)123 1234

i dont know $1 to $2 replacement.

friends did you have any solution for it.

5492 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Located in Australia
  • Has sold $1,000+ on Envato Market
+4 more
Australia says

Hi friends,

I am using javasrcript for string replacement,

i m currently doing replace.(string,tothisstring)

i have a regex for valid north American phone number here it is:
var regex = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;

its check valid phone number like (800)123 1234, 800.123.1456 etc etc formats.

i want to replace (800)123 1234 to (800)123 1234

i dont know $1 to $2 replacement.

friends did you have any solution for it.

Arent:

i want to replace (800)123 1234 to (800)123 1234

The same ??

1578 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

i wanted replace or add HTML element span tag to (800)123 4587

means (800)123 4587 to (800)123 4587

1578 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says
here is function i am using:
var avidno = '1234567890';
function validate () {
    var regex = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;

   if (regex.test(avidno)) {
        alert('bingo');
        var altrstr = avidno.replace(regex, ' <span>$2</span>');
        alert(altrstr);
        // Valid international phone number
    } else {
        alert('uupss');
        // Invalid international phone number
    }
}

validate();

i want regex that replace or add span before and after 12345678 to 123546789

1141 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 100+ items on Envato Market
+2 more
KarmaThemes says

i want regex that replace or add span before and after 12345678 to 123546789

The two numbers are the same, in case you are using some tags, the forum doesn’t display them. It’s not easy to guess what you possibly mean :)

5492 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Located in Australia
  • Has sold $1,000+ on Envato Market
+4 more
Australia says

Always easier to create a fiddle

http://jsfiddle.net/
3096 posts
  • Located in Australia
  • Helps us moderate the forums
  • Has been part of the Envato Community for over 5 years
  • Helped several times protecting Envato Market against copyright violations
+16 more
dtbaker Moderator says

he typed

(800)123 4587 to <span>(800)123 4587</span>
5492 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Located in Australia
  • Has sold $1,000+ on Envato Market
+4 more
Australia says

Ok then use this tool.

http://regex.larsolavtorvik.com/
1578 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says
firennnndddddddsssssss its my mistake if forget that when posting html elements in forum add
 <span>tag before and after </span>

friends here is my exact code:


var avidno = '1234567890';
function validate () {
    var regex = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;

   if (regex.test(avidno)) {
        alert('bingo');
        var altrstr = avidno.replace(regex, ' <span>$2</span>');
        alert(altrstr);
        // Valid international phone number
    } else {
        alert('uupss');
        // Invalid international phone number
    }
}

validate();

i want to replace number(800)123 45678 to

<span>(800)123 4587</span>

Basically i want to add

<span>mynumber</span>
before and after to the number :)

1578 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

ANy one here! to help me.

by
by
by
by
by
by