1737 posts
  • Has been part of the Envato Community for over 4 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 5 years
  • Has referred 1+ members
  • Located in Australia
  • Has sold $1,000+ on Envato Market
+5 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 ??

1737 posts
  • Has been part of the Envato Community for over 4 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

1737 posts
  • Has been part of the Envato Community for over 4 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 5 years
  • Has referred 1+ members
  • Located in Australia
  • Has sold $1,000+ on Envato Market
+5 more
Australia
says

Always easier to create a fiddle

http://jsfiddle.net/
5362 posts
  • Achieved the monthly Community Superstar Award
  • Created a helpful tool/app using the Envato API
  • Became a Top 20 Author of the Month
  • Had an item that was trending
+19 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 5 years
  • Has referred 1+ members
  • Located in Australia
  • Has sold $1,000+ on Envato Market
+5 more
Australia
says

Ok then use this tool.

http://regex.larsolavtorvik.com/
1737 posts
  • Has been part of the Envato Community for over 4 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 :)

1737 posts
  • Has been part of the Envato Community for over 4 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