2

all. I'm looking for a way to replace the bullet character in Greasemonkey. I assume a Regular Expression will do the trick, but I'm not as well-versed in it as many of you.

For example, "SampleSite.com • Page Title" becoming "SampleSite.com Page Title". The issue is that the character has already been parsed by the time Greasemonkey has gotten to it, and I don't know how to make it recognize the symbol.

I've tried these so far, but they haven't worked:

newTitle = document.title.replace(/•/g, "");
newTitle = document.title.replace("•", ""); //just for grins, but didn't work anyway
1
  • Maybe the symbol is actually encoded in the title, if that's not finding it? Commented Dec 29, 2010 at 3:57

3 Answers 3

1

You can do something like this, if Malvolio's solution isn't working

newTitle = document.title.replace(/\&bull\;/g, '');
newTitle = newTitle.replace(/([^a-zA-Z0-9-_\s\/\\\(\)\'\"\&\+\.]+)/g, '');
Sign up to request clarification or add additional context in comments.

1 Comment

This is close to what I need, but it doesn't take page titles with periods or apostrophes into account, so I modified it a bit. Thank you for the original RegEx! newTitle = document.title.replace(/([^a-zA-Z0-9-_\s\/\\()\.']+)/g, '');
1
document.title = document.title.replace(/•/g, "");

works for me.

Comments

1

HTML entities defined by code between & and ; replace · or · (probably in your case) based on page encoding. Better encode html before using RegEx to replace.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.