MyBB Community Forums

Full Version: Badwords Parsing Issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am using MyCodes with myBB word filtering (bad words) to create a type of internal 'smart linking'.



Here is what I have:

MyCodes:
Regular Expression:  \[mylink\]
Replacement: <a href="mylink.wherever"><i>MYLINK</i></a>
Regular Expression: \[mylink2\]
Replacement: <a href="mylink.wherever2"><i>MYLINK2</i></a>

BadWords:
Bad Word:  mylink
Replacement:  [mylink]
Bad Word:  mylink2
Replacement:  [mylink2]

This works absolutely wonderful:



MESSAGE:
"Mylink takes a user to a specific information page."
OUTPUT:
MYLINK takes a user to a specific information page.


MESSAGE:
"Mylink takes a user to a specific information page.  Whereas mylink2 goes to a different page."
OUTPUT:
MYLINK takes a user to a specific information page.  Whereas MYLINK2 goes to a different page.


This is the problem:  when "mylink" (or 'mylink2' etc.) is used multiple times in the same entry, brackets are placed around the link that was used more than once:

MESSAGE:
"Mylink takes a user to a specific informaton page.  Whereas mylink2 goes to a different page.  Users like mylink."
OUTPUT:
[MYLINKtakes a user to a specific information page.  Whereas MYLINK2 goes to a different page.   Users like [MYLINK].








I just learned that "MyCode" will do this all on its own without needing "BadWords" to replace the text with a link.  


In MyCodes do the following:

Regular Expression:  mylink
Replacement: <a href="mylink">mylink</a>

Works like a charm.  For some reason I thought that MyCode required brackets in order to work.
I am just learning how to use MyCode and do not quite understand the syntax.


I want to create a hyperlink from a word (and all forms of that word) but do not want to change the original form of the word.

For example:
link, linking, linked, links  should all point to link but not change the form of the word used in the original post.



This is what I have:


Regular Expression:   link(.*?)
Replacement:  <a href="link.wherever"><i>LINK$1</i></a>



But, if the user types in "linking" the output is this:
LINKing

When I want this:
LINKING

How do I get MyCodes to link the entire form of the word?
Also, is there any documentation about creating custom MyCodes?
There is documentation if you look for it. For example this comment: http://php.net/manual/en/function.preg-match.php#105924 has almost everything you need to know about regexes used for MyCodes.