| 120 | | * Function: value2regExp |
|---|
| 121 | | * Converts a the value of this rule into a regular expression string, |
|---|
| 122 | | * according to the wildcard characters specified. |
|---|
| 123 | | * |
|---|
| 124 | | * Parameters: |
|---|
| 125 | | * wildCard - {<Char>} wildcard character in the above value |
|---|
| | 120 | * APIMethod: value2regex |
|---|
| | 121 | * Converts the value of this rule into a regular expression string, |
|---|
| | 122 | * according to the wildcard characters specified. This method has to |
|---|
| | 123 | * be called after instantiation of this class, if the value is not a |
|---|
| | 124 | * regular expression already. |
|---|
| | 125 | * |
|---|
| | 126 | * Parameters: |
|---|
| | 127 | * wildCard - {<Char>} wildcard character in the above value, default |
|---|
| | 128 | * is "*" |
|---|
| 139 | | var escape = "[^\\"+escapeChar+"]\\"; |
|---|
| 140 | | this.value = this.value.replace(new RegExp(escape+singleChar, "g"), |
|---|
| 141 | | "."); |
|---|
| 142 | | this.value = this.value.replace(new RegExp(escape+wildCard, "g"), |
|---|
| 143 | | ".*"); |
|---|
| 144 | | this.value = this.value.replace(new RegExp(escapeChar, "g"), "\\"); |
|---|
| | 144 | |
|---|
| | 145 | // set UMN MapServer defaults for unspecified parameters |
|---|
| | 146 | wildCard = wildCard ? wildCard : "*"; |
|---|
| | 147 | singleChar = singleChar ? singleChar : "."; |
|---|
| | 148 | escapeChar = escapeChar ? escapeChar : "!"; |
|---|
| | 149 | |
|---|
| | 150 | this.value = this.value.replace( |
|---|
| | 151 | new RegExp("\\"+escapeChar, "g"), "\\"); |
|---|
| | 152 | this.value = this.value.replace( |
|---|
| | 153 | new RegExp("\\"+singleChar, "g"), "."); |
|---|
| | 154 | this.value = this.value.replace( |
|---|
| | 155 | new RegExp("\\"+wildCard, "g"), ".*"); |
|---|
| | 156 | this.value = this.value.replace( |
|---|
| | 157 | new RegExp("\\\\.\\*", "g"), "\\"+wildCard); |
|---|
| | 158 | this.value = this.value.replace( |
|---|
| | 159 | new RegExp("\\\\\\.", "g"), "\\"+singleChar); |
|---|