Using the correct expression and replacement using the widespread regular expressions language, you should be able to transform usernames as long as they follow some consequent pattern. If your incoming username is john.doe_teacher@example.com
and you would like to have it converted to john.doe@example.com
, a regular expression could help you solve this.
One way of doing this is dividing the incoming username into groups by using this expression:
(.*)(_)(.*)(@)(.*)
Here:
the parentheses are creating the groups
period "." indicates any symbol
star "*" means from 0 to many occurrences of the preceding symbol
The five groups can then be used as the replacement to create the new username. Each group is getting a numeral, incremental name where their name and value in the given example would be:
$1 = "jon.doe"
$2 = "_"
$3 = "teacher"
$4 = "@"
$5 "example.com"
To create a new username as an output, use the variables and other symbols to build the replacement. In the given example, having the replacement set to $1$4$5
will transform from john.doe_teacher@example.com
to john.doe@example.com
.
Change case of username
When using just-in-time provisioning and regular expressions for username lookup, you may want to control what case usernames get. By using \L (lowercase) and \U (uppercase) in front of $1 and other replacements (see above examples), you may instruct what casing the username for the newly created user will be.
See more details on the language of regular expressions here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions