RegexSplit resolver returning no values
Brent Putman
putmanb at georgetown.edu
Fri Jan 29 15:13:20 EST 2016
On 1/29/16 6:43 AM, Rod Widdowson wrote:
> ... and you’ve tried the extra (regex="(\\d{5})").
>
> Apart from that, pass, someone the other side of the pond should be able to
> help.
Try one of these, works for me:
^(\d{5}).*$
^(\\d{5}).*$
For a Java String literal, you definitely need the 2nd one, with
backslash escape of the literal backslash, b/c of String literal
requirements. Not sure about here in the IdP, I think you don't need
the escaping when the pattern input is read in as "data". So the 1st
one might work there.
The main thing is: I don't know off-hand exactly why it doesn't work
without the anchors, but it doesn't. That's usually the first thing I
try when a regex doesn't work as I expect: remove ambiguity and
explicitly anchor at both ends.
Fyi, here's the simple Java scratch code I wrote to test. Mirrors what
the RegexSplit- attribute definition does:
public class RegExTest {
public static void main(String[] args) {
String target = "12345 some text 12/01/17";
String patternInput = "^(\\d{5}).*$";
Pattern pattern = Pattern.compile(patternInput);
Matcher matcher = pattern.matcher(target);
if (matcher.matches()) {
System.out.println("SUCCESS: matched!");
System.out.println("Saw group 1: " + matcher.group(1));
} else {
System.out.println("FAIL: Didn't match!");
}
}
}
In that code, without the anchors, the pattern doesn't even "match" the
target string.
> I detest regexps and always have.....
That's because regexps exist in the realm of the Dark Arts, and we
prefer to live in the light...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/users/attachments/20160129/5ec101e6/attachment-0001.html>
More information about the users
mailing list