0

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)

3
  • 1
    See Markdown help. In particular, indent a line four spaces to set it off as code. Commented Apr 26, 2024 at 17:52
  • ...and you can set off text within a sentence by surrounding it with backtics. For example, to display ...string is e.g. "ord1 ord2 ord3 ord4" as ...string is e.g. "ord1 ord2 ord3 ord4". Commented Apr 28, 2024 at 22:22
  • Thanks again Cary. As a beginner the help is really useful. Commented Apr 29, 2024 at 7:22

2 Answers 2

0

To capture everything after the last space, use:

.+\s(.+)$

Adding netscaler's delimiters it would look like this

re#.+\s(.+)$#

The dollar sign anchors the expression to the end of the string. Read about capture grouping (the parentheses) here.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Bluejay, I’ll try this at work on Monday.
Perhaps notice the difference between \s (a whitespace character) and s (the literal character s)
Correct, that is why it includes a slash, we want the whitespace. You can also use a space, as in hitting the spacebar, but this way it captures other types of possible whitespace (tab, for example).
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.