5 Replies - 500 Views - Last Post: 25 June 2013 - 04:03 PM

#1 podooo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 05-July 12

replace()

Posted 25 June 2013 - 01:24 PM

why this doesn't work
        var str = e.source.thehtml; 
	var regMatch = new RegExp("http:\\/\\/\\S+\\.[jJ][pP][eE]?[gG]"); 
	var imagetext = regMatch.exec(str);
	var n =str.replace(/imagetext/g,"");


Is This A Good Question/Topic? 0
  • +

Replies To: replace()

#2 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7649
  • View blog
  • Posts: 12,904
  • Joined: 19-March 11

Re: replace()

Posted 25 June 2013 - 01:43 PM

What do you mean, "doesn't work"? What should it be doing, and what is it doing instead?
Was This Post Helpful? 0
  • +
  • -

#3 podooo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 05-July 12

Re: replace()

Posted 25 June 2013 - 01:53 PM

View Postjon.kiparsky, on 25 June 2013 - 01:43 PM, said:

What do you mean, "doesn't work"? What should it be doing, and what is it doing instead?

it should be removing the img tag from the html content
Was This Post Helpful? 0
  • +
  • -

#4 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7649
  • View blog
  • Posts: 12,904
  • Joined: 19-March 11

Re: replace()

Posted 25 June 2013 - 01:56 PM

You're trying to manipulate the page itself? Or some text that happens to have the same characters in the same order as the source code of the page?
Was This Post Helpful? 0
  • +
  • -

#5 podooo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 05-July 12

Re: replace()

Posted 25 June 2013 - 02:05 PM

View Postjon.kiparsky, on 25 June 2013 - 01:56 PM, said:

You're trying to manipulate the page itself? Or some text that happens to have the same characters in the same order as the source code of the page?

the page itself
Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3530
  • View blog
  • Posts: 10,172
  • Joined: 08-June 10

Re: replace()

Posted 25 June 2013 - 04:03 PM

- line #2: what are the backslashes for? as I see it, you won’t get a match (http:\/\/) this way.
- line #4: imagetext is treated as string, not as variable (i.e. the RegExp is looking for the string "imagetext")
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1