-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Regex match issue when string contains <CR> or <LF> #1632
Comments
@arnaldop yes please submit a PR - I'm also wondering if we should add a |
@arnaldop on second thoughts I'm closing as won't fix as I think this is a very rare use-case, this is the first time this has come up in 4 years. I've made the change to add you can attempt a PR and request to re-open but I need to be convinced this doesn't impact any existing use of |
@ptrthomas, I missed your last message until now. Here is an additional workaround, for anyone looking. I think this one is actually a better workaround. This works with every failing case I mentioned above.
|
because if you have a string, you can call trim() on it any-time
There are backslashes in the failing cases, but this is not the same issue as #988.
When there are
'\r'
or'\n'
characters in the string being matched, the regex match fails. This is probably because Pattern is not being compiled with theMULTILINE
flag. See https://github.com/intuit/karate/blob/ae199b270b9f566847d275760d779456ff7d5289/karate-robot/src/main/java/com/intuit/karate/robot/StringMatcher.java#L45Without testing, it seems that passing the
MULTILINE
flag should fix this issue.A possible workaround might be to trim the string before the problem characters. See below.
Here is a simple feature file showcasing 2 cases that pass, 2 cases that fail, and a sample workaround.
(Could not attach .feature file.)
Thanks for the great tool.
If I am able, I'll try to submit a PR.
The text was updated successfully, but these errors were encountered: