View/Edit #29:regexp_quote

Switch to edit mode.

Name(s): regexp_quote
1:  ":regexp_quote(string)"
2:  " => string with all of the regular expression special characters quoted with %"
3:  string = args[1]
4:  string = strsub(string, "%", "%%")
5:  quoted = ""
6:  while (m = rmatch(string, "[][|()$^.*+?].*"))
7:    quoted = "%" + string[m[$][1]..m[$][2]] + quoted
8:    string = string[1..m[$][1] - 1]
9:  endwhile
10: return string + quoted
11: "Last modified by whiz (#3135) on Sun Jan 13 01:10:30 2008 EST."

Verb arguments: this none this
Verb perms: Readable eXecutable NOT-Debug
Verb owned by: Hacker (#60)

You are not logged in.

[home | help | who | search | setup | code]