MyBB Community Forums

Full Version: Greentext MyCode?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I came across this:

Regular:
(\n|^)>(.*?)(\n|$)

Replacement:
$1<span style="color: #cccc33;">&gt;$2</span>$3

It's intention is to make any text started on a new line with a ">" in front of it a different color. It does not seem to work as it stands right now, anyone want to help me fix it?

Here is how it should work:


Intended input:

>hello guys
>I lie pie
>give me pie

Intended output:

>hello guys
>I lie pie
>give me pie


Current result: [Image: PIZaO94.png]
The issue lies in the fact that the second \n in the regex matches the end of the first line and therefore the next \n isn't found until the end of the second line.

The solution is to use the m flag for the regex (causes ^ and $ to match the start/end of lines). As far as I can tell there isn't a way to get MyBB's MyCode stuff to do that so I think the simplest way would be to write a basic plugin to do it.
Bah time to learn PHP then!
Thanks anyways!
You are not the only pony who has been trying to fix this problem.
Anyone got a solution to it or can fix the code?

Edit: That was easy. Never mind.
I don't mean to tout my own wares, but YourCode allows the 'm' modifier on regex and can handle this easily.
Yourcode doesn't work at all.
Very sorry to gravedig this thread but I was searching everywhere for the solution to this, I fixed it by just putting the myCode in twice: 
[Image: 925e2bd21aab4f10bf40383e24b13d2b.png]