/    Sign up×
Community /Pin to ProfileBookmark

Remove characters from a page

Looking for a simple javascript to remove colons (and possibly other text strings from a page) when it loads.
This looked promsing [URL=”http://javascript.internet.com/snippets/regular-expressions-taster.html”]http://javascript.internet.com/snippets/regular-expressions-taster.html[/URL] but can ‘t seem to get it to work.
Appreciate any help.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@wbportJan 25.2011 — Does something like
[CODE]stuff=stuff.replace(/:/g,"");[/CODE]
work?
Copy linkTweet thisAlerts:
@avdistributionauthorJan 25.2011 — Nope. I found this which does, but it also wipes out the styling associated with the element:
[CODE]$(document).ready(function(){
$("#element").each(function () { //for #element
var s=$(this).text(); //get text
$(this).text(s.replace(/:/g, ' ')); //set text to the replaced version
});
}); [/CODE]


Demo here.
Copy linkTweet thisAlerts:
@avdistributionauthorJan 25.2011 — Ok, I got it thanks to vinhboy and user576875 at stackoverflow. I kind of figured targeting "text" was affecting html tags but didn't know how to correct.
[CODE]$(document).ready(function(){
$("#element").each(function () { //for element
var s=$(this).html(); //get text
$(this).html(s.replace(/:/g, ' ')); //set text to the replaced version
});
}); [/CODE]
×

Success!

Help @avdistribution spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...