Replace in String

S

Shapper.

Hello,

I have the following:

var original = "<span>name at email dot com</span>"
var at = "at";
var dot = "dot";

email = original.text().replace(new RegExp(' ' + at + ' ', 'gi'), '@').replace(new RegExp(' ' + dot + ' ', 'gi'), '.');

I need to find the at and dot var values in original and replace by @ and .

And I need to be case insensitive. So could be AT.
Or any other thing like var at = "ATE".

My Regex expression is not replacing anything.

What am I doing wrong?
 
J

Jukka K. Korpela

27.10.2011 14:04 said:
I have the following:

var original = "<span>name at email dot com</span>"
var at = "at";
var dot = "dot";

email = original.text().replace(new RegExp(' ' + at + ' ', 'gi'), '@').replace(new RegExp(' ' + dot + ' ', 'gi'), '.');

If you look at the error console, you should see something like
"original.text is not a function" there.

If you remove the part ".text()", the value of email becomes
"(e-mail address removed)".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top