Search code examples
regexcitrixadcnetscaler

Netscaler Regex syntax to return last word


I am trying to extract the last word from a user attribute string. The user attribute is AAA.USER.ATTRIBUTE(7) The attribute value string is e.g. "ord1 ord2 ord3 ord4"

If I use the expression

AAA.USER.ATTRIBUTE(7).AFTER_REGEX(re/\s/)

my result is "ord2 ord3 ord4" i.e. i get everything after the first blank space.

I've had a lengthy dialogue with Copilot and an almost as tedious with ChatGPT, they both suggest something like

AAA.USER.ATTRIBUTE(7).AFTER_REGEX(re/s(\w+)$/)

However, that returns a NULL value.

Anyone who knows how I could get that last word?

Both cases:

AAA.USER.ATTRIBUTE(7) = "ord1 ord2 ord3 ord4"

Test 1:

AAA.USER.ATTRIBUTE(7).AFTER_REGEX(re/\s/) 

Expected and actual result: "ord2 ord3 ord4" - all after first whitespace

Test 2:

AAA.USER.ATTRIBUTE(7).AFTER_REGEX(re/s(\w+)$/)

Expected result according to ChatGPT and Copilot: "ord4" Actual result: UNDEF (the result in Netscaler GUI's Expression Evaluator)


Solution

  • I'd like to thank Bluejay for his effort. However, Citrix Netscaler is a world of its own, so it didn't work. The solution was given to me in a Citrix Community; lose the Regex and use Netscaler AppExpert expressions instead. The code that worrked was this:

    AAA.USER.ATTRIBUTE(7).TYPECAST_LIST_T(' ').GET_REVERSE(0)
    

    Thanks again to Bluejay for the effort - and Cary for the Community N00b help