]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/data/util/filter.js.uncompressed.js
1 define("dojo/data/util/filter", ["dojo/_base/lang"], function(lang
) {
3 // dojo/data/util/filter
7 var filter
= lang
.getObject("dojo.data.util.filter", true);
9 filter
.patternToRegExp = function(/*String*/pattern
, /*boolean?*/ ignoreCase
){
11 // Helper function to convert a simple pattern to a regular expression for matching.
13 // Returns a regular expression object that conforms to the defined conversion rules.
17 // *c\*a* -> /^.*c\*a.*$/
18 // *c\*a?* -> /^.*c\*a..*$/
22 // A simple matching pattern to convert that follows basic rules:
23 // * Means match anything, so ca* means match anything starting with ca
24 // ? Means match single character. So, b?b will match to bob and bab, and so on.
25 // \ is an escape character. So for example, \* means do not treat * as a match, but literal character *.
26 // To use a \ as a character in the string, it must be escaped. So in the pattern it should be
27 // represented by \\ to be treated as an ordinary \ character instead of an escape.
30 // An optional flag to indicate if the pattern matching should be treated as case-sensitive or not when comparing
31 // By default, it is assumed case sensitive.
35 for(var i
= 0; i
< pattern
.length
; i
++){
36 c
= pattern
.charAt(i
);
41 rxp
+= pattern
.charAt(i
);
59 rxp
+= "\\"; //fallthrough
66 return new RegExp(rxp
,"mi"); //RegExp
68 return new RegExp(rxp
,"m"); //RegExp