Solved Filtering Messages (RegEx)

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

glowgrew

Active Member
Jan 26, 2017
99
7
0
Perm, Russia
code_language.skript:
# Not working, some1 help please.

function filterIp(v: text) :: boolean:
    {_v} regex doesn't match "(\d{1,3}(\.|\s|-)+\d{1,3}(\.|\s|-)+\d{1,3}(\.|\s|-)+\d{1,3})":
        return false
        stop
    return true

on chat:
    filterIp("%message%") = true:
        cancel event
        send "Idi nahui so svoei reklamoi! (Don't advertise)"
[doublepost=1501827903,1501765020][/doublepost]@Tuke_Nuke, Have TuSKe support RegEx? If so, help please.
 
That's certainly a regex pattern issue, I recommend you to test your pattern before in some online tool, I recommend to use http://www.regexplanet.com/advanced/java/index.html. You put your regex pattern in Regular Expression field and put some messages in Input to try to match, them you hit Test below.

The issue in your code is because the regex is not matching everything. The condition checks if it fully matches a string.
Example:
Code:
if "abc" regex matches "b": #It will return false because it doesn't work as 'contain', but as 'is'. abc != b
if "a1b" regex matches "a\db": #True, because '\d' means 'any number', a1b = a<any number>b
So this way, I recommend to try like this:
code_language.skript:
{_v} regex doesn't match ".*<your regex pattern here>.*":
This way it will match the full message too.
 
  • Like
Reactions: glowgrew
Status
Not open for further replies.