Mapped attribute and regex not returning expected result

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Mapped attribute and regex not returning expected result

Lipscomb, Gary
Hi,

I'm using the following to include all digits up to the first Alpha character from the employeeNumber

<AttributeDefinition xsi:type="Mapped" id="employeeNumber_NO_Apha" sourceAttributeID="employeeNumber">
    <Dependency ref="ldap" />
    <DisplayName xml:lang="en">Employee Number</DisplayName>
    <AttributeEncoder xsi:type="SAML1String" name="urn:mace:dir:attribute-def:employeeNumber" />
    <AttributeEncoder xsi:type="SAML2String" name="urn:oid:2.16.840.1.113730.3.1.3" friendlyName="employeeNumber" />
    <ValueMap>
        <ReturnValue>$1</ReturnValue>
        <SourceValue>^(\d*)(.?)</SourceValue>
    </ValueMap>
  </AttributeDefinition>

If the employeeNumber is
    12345678           it  returns    12345678      as expected
    12345678A        it returns     12345678      as expected
    1234A                 it returns     1234                as expected

    1234A5678        it returns      nothing        but I expected 1234. The attribute is not populated

Using https://regex101.com/ the above expression returns Group 1 as '1234' and Group 2 as 'A'

Any suggestions

Regards

Gary

|   ALBURY-WODONGA   |   BATHURST   |   CANBERRA   |   DUBBO   |   GOULBURN   |   MELBOURNE   |   ORANGE   |   PORT MACQUARIE   |   SYDNEY   |   WAGGA WAGGA   |

LEGAL NOTICE
This email (and any attachment) is confidential and is intended for the use of the addressee(s) only. If you are not the intended recipient of this email, you must not copy, distribute, take any action in reliance on it or disclose it to anyone. Any confidentiality is not waived or lost by reason of mistaken delivery. Email should be checked for viruses and defects before opening. Charles Sturt University (CSU) does not accept liability for viruses or any consequence which arise as a result of this email transmission. Email communications with CSU may be subject to automated email filtering, which could result in the delay or deletion of a legitimate email before it is read at CSU. The views expressed in this email are not necessarily those of CSU.
Charles Sturt University in Australia The Grange Chancellery, Panorama Avenue, Bathurst NSW Australia 2795 (ABN: 83 878 708 551; CRICOS Provider Number: 00005F (National)). TEQSA Provider Number: PV12018
Consider the environment before printing this email.
--
For Consortium Member technical support, see https://wiki.shibboleth.net/confluence/x/coFAAg
To unsubscribe from this list send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Mapped attribute and regex not returning expected result

Tom Scavo
On Mon, Apr 30, 2018 at 6:52 PM, Lipscomb, Gary <[hidden email]> wrote:
>
> If the employeeNumber is
>     12345678           it  returns    12345678      as expected
>     12345678A        it returns     12345678      as expected
>     1234A                 it returns     1234                as expected
>
>     1234A5678        it returns      nothing        but I expected 1234. The attribute is not populated

Not all regex processors are equivalent but these shell commands (on
Mac OS) should give you some idea:

$ foo="12345678
12345678A
1234A
1234A5678"
$ echo "$foo" | sed -E 's/^([0-9]*).*$/\1/'
12345678
12345678
1234
1234

Hope this helps,

Tom
--
For Consortium Member technical support, see https://wiki.shibboleth.net/confluence/x/coFAAg
To unsubscribe from this list send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Mapped attribute and regex not returning expected result

Cantor, Scott E.
In reply to this post by Lipscomb, Gary
> Using https://regex101.com/ the above expression returns Group 1 as '1234'
> and Group 2 as 'A'

Notwithstanding that only actual Java code/testing matters, I believe the issue is that the code only performs replacement if the expression as a whole matches the input, and according to the Java test sites of that nature, the actual match result is false.

e.g. http://www.regexplanet.com/advanced/java/index.html

-- Scott

--
For Consortium Member technical support, see https://wiki.shibboleth.net/confluence/x/coFAAg
To unsubscribe from this list send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Mapped attribute and regex not returning expected result

Lipscomb, Gary
In reply to this post by Lipscomb, Gary
Hi Scott, Tom

Using this ^(\d*)(.?)(.*) now gives the expected results [1]

Have also tested using aacli and results confirmed.

Regards

Gary

[1] results using http://www.regexplanet.com/advanced/java/index.html  (and is now bookmarked)

Test         Target String         matches()         replaceFirst()         replaceAll()         lookingAt()         find()         n [start(n),end(n)] group(n)
1                12345678                Yes                                                                                          Yes                         Yes              0: [0,8] 12345678
                                                                                                                                                                                                           1: [0,8] 12345678
                                                                                                                                                                                                           2: [8,8]
                                                                                                                                                                                                           3: [8,8]

2                12345678A             Yes                                                                                          Yes                          Yes             0: [0,9] 12345678A
                                                                                                                                                                                                           1: [0,8] 12345678
                                                                                                                                                                                                           2: [8,9] A
                                                                                                                                                                                                           3: [9,9]

3                1234A                     Yes                                                                                           Yes                            Yes           0: [0,5] 1234A
                                                                                                                                                                                                           1: [0,4] 1234
                                                                                                                                                                                                           2: [4,5] A
                                                                                                                                                                                                           3: [5,5]

4               1234A5678            Yes                                                                                            Yes                           Yes            0: [0,9] 1234A5678
                                                                                                                                                                                                           1: [0,4] 1234
                                                                                                                                                                                                           2: [4,5] A
                                                                                                                                                                                                           3: [5,9] 5678


-----Original Message-----
From: users [mailto:[hidden email]] On Behalf Of Cantor, Scott
Sent: Tuesday, 1 May 2018 09:12
To: Shib Users <[hidden email]>
Subject: RE: Mapped attribute and regex not returning expected result

> Using https://regex101.com/ the above expression returns Group 1 as '1234'
> and Group 2 as 'A'

Notwithstanding that only actual Java code/testing matters, I believe the issue is that the code only performs replacement if the expression as a whole matches the input, and according to the Java test sites of that nature, the actual match result is false.

e.g. http://www.regexplanet.com/advanced/java/index.html

-- Scott

--
For Consortium Member technical support, see https://wiki.shibboleth.net/confluence/x/coFAAg
To unsubscribe from this list send an email to [hidden email]
--
For Consortium Member technical support, see https://wiki.shibboleth.net/confluence/x/coFAAg
To unsubscribe from this list send an email to [hidden email]