le_ba_nam
(le ba nam)
October 26, 2020, 4:09am
1
I have my regex like this:
def m = /(.+)webservice.*/.matcher(x);if ( m.matches()) {return m.group(1);
The problem is it just match when my string have no "\n" like :
"mbccs_getStatusIncorrectProfile webservice does not exist"
and fail:
"mbccs_getStatusIncorrectProfile webservice does not exist\n"
How can I catch in second case? And even with other characters like "\r" ...Thanks.
Hi @le_ba_nam
The \
character is a special char in Regex so you need to escape it.
Can you try the following
String escape(def x) { /([\\])/.matcher(x).replaceAll('\\') };
def m = /(.+)webservice.*/.matcher(escape(x));
if ( m.matches()) {return m.group(1);
And let me know if it worked?
Cheers!
system
(system)
Closed
November 27, 2020, 10:05am
3
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.