diff --git a/src/main/java/net/aufdemrand/denizen/objects/dList.java b/src/main/java/net/aufdemrand/denizen/objects/dList.java
index 8f290fde2c..07132ea36b 100644
--- a/src/main/java/net/aufdemrand/denizen/objects/dList.java
+++ b/src/main/java/net/aufdemrand/denizen/objects/dList.java
@@ -712,6 +712,25 @@ else if (dEntity.matches(get(n))) {
}
}
+ // <--[tag]
+ // @attribute
]>
+ // @returns dList(Element(Number))
+ // @description
+ // returns all the numbered locations of elements within a list,
+ // or an empty list if the list does not contain that item.
+ // EG, .find[two] on a list of "one|two|three|two" will return "2|4".
+ // TODO: Take multiple inputs? Or a regex?
+ // -->
+ if (attribute.startsWith("find_all_partial") &&
+ attribute.hasContext(1)) {
+ dList positions = new dList();
+ for (int i = 0; i < size(); i++) {
+ if (get(i).toUpperCase().contains(attribute.getContext(1).toUpperCase()))
+ positions.add(String.valueOf(i + 1));
+ }
+ return positions.getAttribute(attribute.fulfill(1));
+ }
+
// <--[tag]
// @attribute ]>
// @returns dList(Element(Number))
@@ -731,6 +750,24 @@ else if (dEntity.matches(get(n))) {
return positions.getAttribute(attribute.fulfill(1));
}
+ // <--[tag]
+ // @attribute ]>
+ // @returns Element(Number)
+ // @description
+ // returns the numbered location of the first partially matching element within a list,
+ // or -1 if the list does not contain that item.
+ // EG, .find[two] on a list of "one|two|three" will return "2".
+ // TODO: Take multiple inputs? Or a regex?
+ // -->
+ if (attribute.startsWith("find_partial") &&
+ attribute.hasContext(1)) {
+ for (int i = 0; i < size(); i++) {
+ if (get(i).toUpperCase().contains(attribute.getContext(1).toUpperCase()))
+ return new Element(i + 1).getAttribute(attribute.fulfill(1));
+ }
+ return new Element(-1).getAttribute(attribute.fulfill(1));
+ }
+
// <--[tag]
// @attribute ]>
// @returns Element(Number)