Allow custom regex flags
Fixes Issue #29 For example, match "word" without case sensitivity, match globally: word/ig If you want to match a literal slash, escape it with a backslash: \/
This commit is contained in:
parent
6ae16d5671
commit
78ecc042d6
2 changed files with 20 additions and 6 deletions
|
|
@ -635,8 +635,15 @@ function updateChatFilters(entries) {
|
|||
.appendTo($("<td/>").appendTo(newfilt));
|
||||
var cback = (function(regex, replace) { return function() {
|
||||
if(regex.val() && replace.val()) {
|
||||
var re = regex.val();
|
||||
var flags = "g";
|
||||
var slash = re.lastIndexOf("/");
|
||||
if(slash > 0 && re[slash-1] != "\\") {
|
||||
flags = re.substring(slash+1);
|
||||
re = re.substring(0, slash);
|
||||
}
|
||||
try {
|
||||
var dummy = new RegExp(regex.val(), "g");
|
||||
var dummy = new RegExp(re, flags);
|
||||
}
|
||||
catch(e) {
|
||||
alert("Invalid regex: " + e);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue