RegexSplit resolver returning no values

Morris, Andi amorris at cardiffmet.ac.uk
Mon Feb 1 08:13:50 EST 2016


OK great advice here. I have a working regex now, but just wondered why mine wasn't working to start with. I'll do some more testing at this end, but my primary problem is now solved.

Thanks to everyone that replied.

Cheers,
Andi

From: users [mailto:users-bounces at shibboleth.net] On Behalf Of Brent Putman
Sent: 29 January 2016 20:14
To: users at shibboleth.net
Subject: Re: RegexSplit resolver returning no values


On 1/29/16 6:43 AM, Rod Widdowson wrote:

... and you've tried the extra (regex="(\\d{5})<file:///\\d%7b5%7d)>").



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}).*$<file:///\\d%7b5%7d).*$>

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}).*$<file:///\\d%7b5%7d).*$>";

        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...

________________________________

[Cardiff Metropolitan University - 150 years of nurturing talent]<http://www.cardiffmet.ac.uk/cardiffmet150>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/users/attachments/20160201/1f39a9fb/attachment.html>


More information about the users mailing list