Skip to content

[SOLVED] Failing to Replace article title using regex of (Hashtags, URLs). Am i doing it right? #1114

Answered by martinrotter
Starboy-Xo asked this question in Q&A
Discussion options

You must be logged in to vote

OK, so first, in order to have your regexp syntax recognized, you have to use regex "/ /" syntax. Instead of "" use // as begin-end syntax of your regex, also add "g" modifier to replace all occurences.

Like this:

function filterMessage()
{
  msg.title = msg.title.replace(/#[a-z0-9_]+/g, ' ');

  return MessageObject.Accept;
}

Similarly do the same for your second line which I believe also contains logical regex error.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@Starboy-Xo
Comment options

Comment options

You must be logged in to vote
1 reply
@Starboy-Xo
Comment options

Answer selected by Starboy-Xo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants