BlackBeltPanda

RegexMisc

May 15th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. Examples of miscellaneous useful regex:
  2.  
  3. #TRIM out excessive letter spam
  4. match (?i)(.)\1{3}
  5. then replace $1
  6.  
  7. Explanation:
  8. "(?i)" is the case-insensitive flag so it will match capital and lower-case letters.
  9. "(.)" is a regex capture group that matches any character except a new line.
  10. "\1" is the first group we captured. This will match whatever we just matched again.
  11. "{3}" is used to match exactly 3 of the previous match, which is group 1.
  12. We use "then replace $1" to replace the match with group 1.
  13. In the case of the string "AhhHhhhHHHhhHhhhhh!", it will capture all the letters in which there are 3 in a row and replace them with the captured group, which was the single letter. With how ChatControl works, this will run each time until it no longer matches 3 of the letter in a row, giving us a final result of "Ah!".
  14.  
  15. #Prevent owner hate
  16. match owner is (?:a|an) (?:dick|noob|loser|ass|bitch|retard)
  17. id ServerHate
  18. then replace i luv justin beiber
  19. then notify chatcontrol.notify.rulesalert &8[&7ID {ruleID}&8] &7{player}: &f{message}
  20. then console kick {player} &cI don't think so.
  21.  
  22. Explanation:
  23. This one uses passive groups ("(?:<regex_here>)") to check for words that add up to an unpleasant phrase regarding the owner. We use ChatControl's "then replace" to replace the matched string with another one. In this case an appropriate "i love justin beiber". We also use "notify" to notify any players online who have the specified permission about the incident. Then we use "console" to run a command from console; in this case we use the kick command to kick the player.
  24.  
  25. #Replace dafuq with wtf
  26. match (?i)dafuq
  27. id rude
  28. then replace wtf
  29.  
  30. #Deny any chat containing the swastika Unicode symbol
  31. match \u534D|\u5350
  32. id rude
  33. then deny
Advertisement
Add Comment
Please, Sign In to add comment