Add an exception (with RegExp)

Asked Aug 21, 2021·14 replies·Last activity 4 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

Hello.
I have banned the use of other languages using RegExp
Adding expressions like /[\u0080-\u00FF]+ to the blacklist.
But I met a problem. It consists in the fact that some characters are used in all languages. For example, ° - when a person tells what the weather is like. Or other characters that are included in the forbidden block.
My question is: Is it possible to make exceptions?
For example /[\u0080-\u00FF]+ is forbidden, but U00B0, U00F7 and U01C3 are allowed
How do I write this?

14 replies

Have you considered using the ^ not operator to match to only the language you want and selected characters like this?

/[^\x00-\x7F\u00B0\u00F7\u01C3]/g

This bans all non English characters except the three you listed I’m presuming you want only English but feel free to make it however you want.

Ok try this:

/(?=[^\u00B0\u00F7\u01C3])[\u0080-\u00FF]/

However as a side note you don’t really need to include the \u01C3 as that’s not within the range of the set.

I know that. I have a difficulty with the correct formulation of the formula

Quirky Fox said:
/(?=[^\u00B0\u00F7\u01C3])[\u0080-\u00FF]+/

I checked it out. It doesn't work at all.
I need certain characters from the table to be allowed in the chat. In this case, but the entire block should be blocked.

Try the code above again I got rid of the + at the end that should work now from my testing.

Quirky Fox said:
/(?=[^\u00B0\u00F7\u01C3])[\u0080-\u00FF]/

The new version doesn't work either

Really is it banning the symbols or not banning them at all?

does not prohibit at all. The nightbot does not see this command

Can you show me what your typing in chat?

Yeah that’s weird from my testing with a regex checker it worked I’ll look more in depth into it later when I can with nightbot.

No one has a solution?
There is a ban on /[\u0080-\u00FF]+/
Need to allow the characters in this block u00B0, u00CB and u00EB
How to do it?

Didn't find your answer? The community is on Discord.

Ask on Discord