Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #7718 > unrolled thread
| Started by | "Shapper." <mdmoura@gmail.com> |
|---|---|
| First post | 2011-10-27 04:04 -0700 |
| Last post | 2011-10-27 14:46 +0300 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.javascript
Replace in String "Shapper." <mdmoura@gmail.com> - 2011-10-27 04:04 -0700
Re: Replace in String "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2011-10-27 14:46 +0300
| From | "Shapper." <mdmoura@gmail.com> |
|---|---|
| Date | 2011-10-27 04:04 -0700 |
| Subject | Replace in String |
| Message-ID | <3856471.2893.1319713450524.JavaMail.geo-discussion-forums@yqnx19> |
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?
--
Thank You,
Miguel
[toc] | [next] | [standalone]
| From | "Jukka K. Korpela" <jkorpela@cs.tut.fi> |
|---|---|
| Date | 2011-10-27 14:46 +0300 |
| Message-ID | <j8bga1$ijj$1@dont-email.me> |
| In reply to | #7718 |
27.10.2011 14:04, "Shapper." wrote:
> 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
"name@email.com".
--
Yucca, http://www.cs.tut.fi/~jkorpela/
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web