# 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="/files/ZbIV9agGAYzNKOFywlZU" 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="/files/rEKHPJ5Z3bwXyQokLnDP" 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fylr.io/tutorials/auth/saml/manipulating-attributes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
