Jump to content
Welcome to our new Citrix community!

Nested expressions or returning a string

Recommended Posts

Nested expressions can be done but they are sometimes tricky to work with.  

Your first issue is that regex_match returns a boolean true/false result. So it can't do what you want it to do anyway.



Your asking does user attribute (3) contain ("<this thing>") where <this thing> is the output of regex match: true/false.  


Based on your previous post:

url1 url2 url3


The expression



does not work,because the url is




I think, you need to start with aaa.user.attribute(3).contains("<thing you are looking for>")

What determines the URL you are looking for a static string or something else in the request?

And then we can try to come up with an expression. the example just doesn't make it easy to see what you want to do or how to  do it.



Link to comment
Share on other sites

Hi Rhonda,

thanks for your reply. I found myself, that regex_match was wrong. i thing regex_select returns the selected string.

i changed the expression to this


the correct url would be something like









Link to comment
Share on other sites

Are you trying to see if if the User.Attribute(3) contains the thing your regex_select is looking for?

Or are you trying to use regex_select to parse the output of User.attribute(3) (meaning does the attribute contain a specific string)


So what I need to understand is

what value(s) does user.attribute(3) contain

what value do you want to find (and what identifies that value)


And then we can figure out how to do it.

I don't believe your expression is doing what you want.  

Link to comment
Share on other sites

So a user is making a connection to a specific URL:  http://server.domain.com/apex/rest/<targetvalue>/<stuff>

And during this process you want to see if the URL path 3rd element they are currently connecting to is in the possible list of URLs in the user attribute (3).

<attrib1>,<attrib2>,/apex/rest/url1/stuff /apex/rest/url2/stuff /apex/rest/url3/stuff,<otherattrib>


If this still isn't want you are doing you really do need to explain where you get the target value you are looking for in the user attribute 3. The more specific your example the better someone can help you out.


You need a TRUE if their current URL Path 3 is in the list of URLs in attribute(3)?


NOTE: During testing, I used a "header" test as it was easier to simulate in the evaluator to get close.  I'll give that example at end.



The you get your Target URL or Path from the current request is assuming this is the user's current request:

Example 1:  /apex/rest/urlA/stuff.php

http.req.url.path is /apex/rest/urlA/stuff.php

http.req.url.path.get(3) is urlA



The basic way to extract the value from user attribute 3 is,

For Example 2:  <attrib1>,<attrib2>,/apex/rest/urlA/stuff.php /apex/rest/url2/stuff /apex/rest/url3/stuff,<otherattrib>

aaa.user.attribute(3) returns /apex/rest/urlA/stuff.php /apex/rest/urlB/stuff /apex/rest/urlC/stuff


If the User's Path in full in Example 1 is part of the string returned in Example 2, you might just be able to do this:



Basically it evaluates if (Example2 contains string in Example 1):   /apex/rest/urlA/stuff.php /apex/rest/urlB/stuff /apex/rest/urlC/stuff contains /apex/rest/urlA/stuff.php

This is TRUE.

You don't need a regex and you need to try recursively parse the attribute string...which is the really hard part (and may not be able to be done; I have to think on it... a lot of risks of undefined results if not done well).  And if someone else knows an easy way to iterate multiple comparisons, please jump in. I don't know a good way to do that off the top of my head, so I'm trying to do this in a way where you don't need to iterate.


If that's not going to work, I want to make sure I understand the problem you are trying to solve before doing any more policy work on it.


But maybe these examples can help you out:

Note, to split the first <URL> out of Attribute(3), would be done kind of like this:

For Example 3:  <attrib1>,<attrib2>,/apex/rest/urlA/stuff.php /apex/rest/url2/stuff /apex/rest/url3/stuff,<otherattrib>

aaa.user.attribute(3) is /apex/rest/urlA/stuff.php /apex/rest/url2/stuff /apex/rest/url3/stuff

To grab first <url> before a <space>:

aaa.user.attribute(3).before_str(" ") is /apex/rest/urlA/stuff.php

To typecast as URL to do URL operations:

aaa.user.attribute(3).before_str(" ").typecast_HTTP_URL_T

Then you can do url path parsing like:

aaa.user.attribute(3).before_str(" ").typecast_http_url_t.path.get(3)  is urlA


However, trying to get to the second and third string is much harder at this point.


Also, if you want to test in the evaluator, try making a HEADER with your expected user attribute string and then you can play with the evaulator to see how you can parse it.


Here's the mock up I did in the HEADER to compare against a current URL path (as working with user attributes wasn't going to be feasible):

In Expression Evaluator,

- Create an HTTP Request

- Then get a sample GET REQUEST from the evaluator
Modify the GET line like:

GET /apex/rest/url1/infos HTTP/1.1

Add NEW Header Test:

Test: /apex/rest/url1/infos /apex/rest/url2/other


Example 1:  http.req.header("test")  returns /apex/rest/url1/infos /apex/rest/url2/other

Example 2: http.req.url.path returns the target of the GET in this example:  /apex/rest/url1/infos /apex/rest/url2/other

http.req.header("test").before_str(" ").contains(http.req.url.path)

and other variations...

I don't think you need a regex inspection here. But it just depends on the criteria you have.


  • 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...