查找引用文本并使用类似于4chan greentext的javascript将其着色为绿色?

时间:2017-06-05 15:06:33

标签: javascript jquery regex

例如:

等文字
>11 years old
>twin brother dies
>parents dont let me go to his funeral or tell me where it is
>tells me it would be innapropriate to be there as it could confuse people    
i dided

如何匹配元素中的>并将其变为绿色?功能应该类似于4chans“greentext”,这意味着那里的“我划分”部分不应该变成绿色

1 个答案:

答案 0 :(得分:1)

试试这个,它匹配>在行的开头,然后在它之后的任何东西(在同一行)

>.*/g

/g用于全局匹配。

示例:

https://regex101.com/r/WXEoaW/2