# manipulating attributes

## Replacing strings in attributes

Our attribute syntax can replace strings. This syntax is part of our attribute matching (fylr 6.20 and newer):

```
%(key||search||replacement)s
```

Where `search` is the regexp matching what is then replaced with `replacement`.

The regular expressions syntax rules: <https://pkg.go.dev/regexp#Regexp.ReplaceAllString>.

Example: `%(email||^.*=||)s`, in context:

When a user logs in with attribute email equal to `urn:campus:1:mail=ben@example.com` and attribute mapping Target:Email `%(email||^.*=||)s` then his email address in fylr will be just `ben@example.com`, because the search part matches all up to the equal sign and the replacement is empty.

<figure><img src="https://4100607288-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAdRFzQASDY2Elfdm3wXW%2Fuploads%2F3VisBRVNZyUS88pk7Gqi%2Fimage.png?alt=media&#x26;token=4b6ce450-783a-4575-8af2-de74a296f142" alt=""><figcaption></figcaption></figure>

## Multi-Value-Attributes

If there are multiple values for e.g. department, a 4th parameter can now be used to concatenate multiple values into one.

```
%(key||search||replacement||;)s
```

Example: `%(dpmt||^.*=||||;)s`, in context:

When a user logs in with these two attributes `urn:campus:1:dpmt=marketing` and `urn:campus:2:dpmt=sales` , the attribute mapping is done like above and in fylr the department will be

`marketing;sales`

## pick first attribute

If an attribute is replaced like this `%(mail|email)s`, fylr now uses the first entry which is not empty as replacement.

## Using JavaScript

You can edit incoming data from SAML via Javascript in the following field:<br>

<figure><img src="https://4100607288-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAdRFzQASDY2Elfdm3wXW%2Fuploads%2FAEuGWxiZPe9ZK3k3LX5p%2Fimage.png?alt=media&#x26;token=30ddf255-c14e-46b7-90b3-ea0124a0e555" alt=""><figcaption></figcaption></figure>

Each user is processed separately and is stored in the javascript object `entry` with string arrays as values. Changes configured in this field are done before the IDP data is mapped to the fylr user.
