Hans Lindahl Posted April 26 Share Posted April 26 (edited) In user attribute AAA.USER.ATTRIBUTE(7) I have a string value "word1 word2 word3 word4", and I need a way to return only the last word Using the expression AAA.USER.ATTRIBUTE(7).AFTER_REGEX(re/\s/) i get everything after the first blank space, i.e. "word2 word3 word4" I've tried both ChatGPT and Copilot, both suggest AAA.USER.ATTRIBUTE(7).AFTER_REGEX(re/s(\w+)$/) - but that returns a NULL value. I've tried different regex versions att regex101, but just can't find one that fits Netscaler. Anyone out there who might be able to help me? Edited April 26 by Hans Lindahl spelling error Link to comment Share on other sites More sharing options...
Solution Rick Davis Posted April 26 Solution Share Posted April 26 Instead of Regex, use inbuilt AppExpert expressions for this use case. In your example, we can use the space character (' ') as the separator for a list of words. Then we can choose the first or last word from the list. Here is your AppExpert expression: AAA.USER.ATTRIBUTE(7).TYPECAST_LIST_T(' ').GET_REVERSE(0) I used the NetScaler Expression Evaluator to make sure it returns the desired result: 1 Link to comment Share on other sites More sharing options...
Hans Lindahl Posted April 30 Author Share Posted April 30 HUUUUUGE thanks to Rick for helping me out here. You are my knight in shining armour 🙌 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now