Skip to content
This repository was archived by the owner on Nov 27, 2018. It is now read-only.

Optional "modifiers" parameters for data store regex find #9

Merged
merged 1 commit into from
Jun 5, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions debug/abaaso.js
Original file line number Diff line number Diff line change
Expand Up @@ -1301,13 +1301,15 @@ if (typeof global.abaaso === "undefined") global.abaaso = (function () {
* Finds needle in the haystack
*
* @method find
* @param {Mixed} needle String, Number or Pattern to test for
* @param {Mixed} haystack [Optional] The field(s) to search
* @param {Mixed} needle String, Number or Pattern to test for
* @param {Mixed} haystack [Optional] The field(s) to search
* @param {String} modifiers [Optional] Regex modifiers
* @return {Array} Array of results
*/
find : function (needle, haystack) {
find : function (needle, haystack, modifiers) {
try {
if (typeof needle === "undefined") throw Error(label.error.invalidArguments);
if (typeof modifiers !== "string" || String(modifiers).isEmpty()) modifiers = "gi";

var h = [],
n = typeof needle === "string" ? needle.explode() : needle,
Expand Down Expand Up @@ -1337,7 +1339,7 @@ if (typeof global.abaaso === "undefined") global.abaaso = (function () {
for (y = 0; y < nth2; y++) {
f = h[x];
p = n[y];
r = new RegExp(p, "gi");
r = new RegExp(p, modifiers);
s = this.records[i].data[f];
if (!keys[this.records[i].key] && r.test(s)) {
keys[this.records[i].key] = i;
Expand Down