Hello Developer Community!
I'm currently working on developing some Ansible playbooks to manage Citrix NetScaler configuration and would like to ask for some help about the following.
I have the following configuration line what I would like to parse with TextFSM:
add lb vserver VS_ssl_443_testapps SSL 0.0.0.0 0 -persistenceType RULE -timeout 30 -rule "HTTP.REQ.COOKIE.VALUE(\"JSESSIONID\")" -resRule "HTTP.RES.SET_COOKIE.COOKIE(\"JSESSIONID\").VALUE(\"JSESSIONID\")" -cltTimeout 600 -td 1
I would need to write a regex matching any content between double quotes after the -rule keyword. The content between the start and end double quotes can contain more double quotes.
"HTTP.REQ.COOKIE.VALUE(\"JSESSIONID\")"
My problem is that, in case there is an optional -resRule keyword defined after the -rule keyword and the text after the -resRule keyword also contains double quotes, the content match includes contents after both -rule and -resRule keywords.
Is it possible to define a list of "unwanted" keywords when the content between the starting and ending double qoutes contains any of the keywords, the match ends at the last double qoute before the unwanted keyword?
So for example,
I'm trying to play with lookaheads and non-capture groups, but with no luck.
https://regex101.com/r/UkPr05/1
(((\")(.*)(\"))(?:( -resRule.*)))
Thank You very much in advance!
You can use the expression -rule\s*(\"(\\\"|[^\"])*\")
that will take only the quoted value for the argument -rule
, the key changes are
-rule
,https://regex101.com/r/HoCM1v/1/
If you wanted to included unquoted parameters as well you could use -rule\s*(\"(\\\"|[^\"])*\"|\S+)
, where the \S+
represents characters up to next space.