Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 1.07 KB | None | 0 0
  1. ;   $wc2re(<wildcard text>).cs
  2. ;     -Converts <wildcard text> to a regex pattern
  3. ;     -if .cs is specified, the match is case sensative
  4. ;
  5. ; How to do it:
  6.  
  7. ;declare the alias
  8. alias wc2re {
  9.  
  10.   ;setup variable to be used when formatting
  11.   var %subbed
  12.  
  13.   ;removing any repeats of * ie: "***" becomes "*"
  14.   var %subbed = $regsubex($1-,/\*+/g,*)
  15.  
  16.   ;Using $regsubex(), replace all "special" regex characters in %subbed with their escaped values.
  17.   ;Special characters being: |[]{}()\/.
  18.   %subbed = $regsubex(%subbed,/([|\[\]{}()\\\/.])/g,\\t)
  19.  
  20.   ;After subbing the regex special characters, replace ?'s with .'s and *'s with .*'s
  21.   %subbed = $replace(%subbed,?,.,*,.*)
  22.  
  23.   ;Once we have everything substituted, we need to wrap the pattern with /^$/ so the pattern will try to match the whole string, instead of just parts of it
  24.   %subbed = /^ $+ %subbed $+ $ $+ /
  25.  
  26.   ;Check to see if the $prop was "cs" and if not tack "i" onto the end of the pattern to make it case insensative
  27.   if ($prop != cs) { %subbed = %subbed $+ i }
  28.  
  29.   ;now return the result
  30.   return %subbed
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement