Skip to content
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

Propblems with regular expression like strings #1

Open
berhoel opened this issue Mar 8, 2016 · 1 comment
Open

Propblems with regular expression like strings #1

berhoel opened this issue Mar 8, 2016 · 1 comment

Comments

@berhoel
Copy link

berhoel commented Mar 8, 2016

I had problems replacing string that looked like regular expressions, e.g. replacing

a+b+c

by

xxxxx

does not work, because in co.codewizards.svndumptransformer/src/main/java/co/codewizards, line 230

if (string.contains(me.getKey()))

me.getKey() is used as search string, whereas in line 231

string = string.replaceAll(me.getKey(), me.getValue());

it is used as regular expression.

replaceing line 230 by

if (string.split(me.getKey()).length > 0)

did work for me.

If Regular expressions should be disallowed in the replacement,

import java.util.regex.Pattern;

should be added and line 231 should be rewritten

string = string.replaceAll(Pattern.quote(me.getKey()), me.getValue());

@nlmarco
Copy link
Owner

nlmarco commented Mar 8, 2016

Thanks a lot for this bug report! I didn't intend this tool to support regular expressions. Of course, someone might need this in the long run, but it seems neither you nor me needed it, so far.

Since regex are more complex and most of the times not needed, they should be added optionally in the future; if someone really ever needs them. Maybe with an option being disabled by default.

As soon as I have time, I'd go for the 2nd solution proposed by you (in line 231).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants