Skip to content

Commit

Permalink
Add <util.substr[text].before[text]> tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcernat committed Jun 20, 2013
1 parent 1d6b7f2 commit 1163f9f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/net/aufdemrand/denizen/tags/core/UtilTags.java
Expand Up @@ -60,24 +60,26 @@ else if (type.equalsIgnoreCase("SUBSTR")
|| type.equalsIgnoreCase("SUBSTRING")) {
String text = event.getTypeContext();
int from = 1;
int to = text.length() + 1;

if (subType.equalsIgnoreCase("AFTER")) {
from = text.toUpperCase().indexOf(subTypeContext) + subTypeContext.length() + 1;
}

if (subType.equalsIgnoreCase("BEFORE")) {
to = text.toUpperCase().indexOf(subTypeContext) + 1;
}

try {
if (subType.equalsIgnoreCase("FROM"))
from = Integer.valueOf(subTypeContext);
} catch (NumberFormatException e) { }
int to = text.length() + 1;

try {
if (specifier.equalsIgnoreCase("TO"))
to = Integer.valueOf(specifierContext);
} catch (NumberFormatException e) { }



if (to > text.length())
to = text.length() + 1;

Expand Down

0 comments on commit 1163f9f

Please sign in to comment.