1 if(!dojo._hasResource["dojo.data.util.filter"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojo.data.util.filter"] = true;
3 dojo.provide("dojo.data.util.filter");
5 dojo.data.util.filter.patternToRegExp = function(/*String*/pattern, /*boolean?*/ ignoreCase){
7 // Helper function to convert a simple pattern to a regular expression for matching.
9 // Returns a regular expression object that conforms to the defined conversion rules.
13 // *c\*a* -> /^.*c\*a.*$/
14 // *c\*a?* -> /^.*c\*a..*$/
18 // A simple matching pattern to convert that follows basic rules:
19 // * Means match anything, so ca* means match anything starting with ca
20 // ? Means match single character. So, b?b will match to bob and bab, and so on.
21 // \ is an escape character. So for example, \* means do not treat * as a match, but literal character *.
22 // To use a \ as a character in the string, it must be escaped. So in the pattern it should be
23 // represented by \\ to be treated as an ordinary \ character instead of an escape.
26 // An optional flag to indicate if the pattern matching should be treated as case-sensitive or not when comparing
27 // By default, it is assumed case sensitive.
31 for(var i = 0; i < pattern.length; i++){
32 c = pattern.charAt(i);
37 rxp += pattern.charAt(i);
55 rxp += "\\"; //fallthrough
62 return new RegExp(rxp,"i"); //RegExp
64 return new RegExp(rxp); //RegExp