I had to extract a the first letter of a username using Appsense Policy Configuration within Environment Manager. I would have hoped there was a trim functionality natively available, however none were found in the version that was dealt with.
Therefore a bit of optimized search had to be performed. As far as I can see this is faster than executing a script, but perhaps a bit more work to setup initially.
Below each one I then parsed through the letters that the regular expression matched (A-E for example) and once a match was hit – set the environment variable FIRSTLETTER to the matching letter.
Search was for the letter A as a sample; *\a*
For each specific letter I used a query and not a regular expression.
I created an Appsense template for EM that you can download, which contains a reusable node!