[Ext] Re: Scripted Attribute / weird issue

Bryan Wooten bryan.wooten at utah.edu
Fri Jul 29 16:51:41 EDT 2016


Thanks Brent,

I tried all kinds of escape syntax, none worked on any javascript strings.

But I found a “solution”.

I found that var string = basicAttribute.getValues().toString().replace(“$”,”-“); will successfully get rid of the special char and then I could just split() on ‘-‘.

However for some reason string winds up with the special char ‘[‘ and ‘]’… And those have the same issue as ‘$’…

Anyway with much clugdy code I got the results I needed.

Lesson learned: don’t use special chars for delimiters.

From: Brent Putman <putmanb at georgetown.edu<mailto:putmanb at georgetown.edu>>
Reply-To: "users at shibboleth.net<mailto:users at shibboleth.net>" <users at shibboleth.net<mailto:users at shibboleth.net>>
Date: Friday, July 29, 2016 at 1:00 PM
To: "users at shibboleth.net<mailto:users at shibboleth.net>" <users at shibboleth.net<mailto:users at shibboleth.net>>
Subject: [Ext] Re: Scripted Attribute / weird issue



On 7/29/16 12:35 PM, Bryan Wooten wrote:
          element = ca[0].split("$");

So the split on ‘,’ on the courses string works, but the split on ‘$’ on ca[0] doesn’t do anything.

If I change ‘$’ to ‘2’ it will split on the ‘2’.

Also note that a replace on ‘$’ doesn’t work either.

Any ideas? My google foo is totally failing….


Well, the input to the Java String split() function is a regular expression, and the '$' is a special character. [1]

So if you want to split on a literal '$', you have to escape it.   Try split("\$").  (Or if that doesn't work try split("\\$").  In some cases with string literals in Java you have to have 2 escape characters and I can never remember when/why.  Don't know which case this is.)



[1] https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#sum
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/users/attachments/20160729/d3087e42/attachment.html>


More information about the users mailing list