Jump to content
Updated Privacy Statement

Regex to find last part of string

Go to solution Solved by Rick Davis,

Recommended Posts

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 by Hans Lindahl
spelling error
Link to comment
Share on other sites

  • Solution

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:



I used the NetScaler Expression Evaluator to make sure it returns the desired result:


  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...