-
-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🚀 Add regex replace #4323
🚀 Add regex replace #4323
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have much to add other than what TP already commented
Co-authored-by: TPGamesNL <29547183+TPGamesNL@users.noreply.github.com>
Co-authored-by: APickledWalrus <apickledwalrus@gmail.com>
Co-authored-by: TPGamesNL <29547183+TPGamesNL@users.noreply.github.com>
Co-authored-by: Patrick Miller <apickledwalrus@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Might be worth it to add a test or two.
bd134d0
to
3f08853
Compare
- Add regex replace first - removed unused vars
"regex:(replace [using] regex|regex replace) %strings% in %strings% with %string%", | ||
"regex:(replace [using] regex|regex replace) %strings% with %string% in %strings%", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could also just check the matchedPattern here rather than a regex parse tag
@Override | ||
public String toString(@Nullable Event event, boolean debug) { | ||
if (replaceFirst) | ||
return "replace first " + needles.toString(event, debug) + " in " + haystack.toString(event, debug) + " with " + replacement.toString(event, debug) | ||
return "replace first " + needles.toString(event, debug) + (replaceRegex ? " (regex) " : "") + " in " + haystack.toString(event, debug) + " with " + replacement.toString(event, debug) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be removed as it seems replace first regex is not possible
+ "(case sensitive: " + caseSensitive + ")"; | ||
return "replace " + needles.toString(event, debug) + " in " + haystack.toString(event, debug) + " with " + replacement.toString(event, debug) | ||
return "replace " + needles.toString(event, debug) + (replaceRegex ? " (regex) " : "") + " in " + haystack.toString(event, debug) + " with " + replacement.toString(event, debug) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this toString does not seem to reflect the regex replace pattern?
might be better to make a separate case like with replaceFirst. or, it might even be better to just use a stringbuilder.
Co-authored-by: Patrick Miller <apickledwalrus@gmail.com>
Continued in #7167 |
Description
This PR aims to add
regex replace
to the replace effectreplace first
patterns not using%strings%
in the haystackNote: Currently if there are any regex pattern exceptions/errors they will be ignored.
Target Minecraft Versions: Any
Requirements: None
Related Issues: None