1665 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
+1 more
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 ??

1665 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
+1 more
webdesignerart says

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

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

1665 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
+1 more
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/
3315 posts
  • Provided great contribution to our forums
  • Nominated Community Superstar of the month
  • Helps us moderate the forums
  • Has been part of the Envato Community for over 5 years
+18 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/
1665 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
+1 more
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 :)

1665 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
+1 more
webdesignerart says

ANy one here! to help me.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by