Regex question


#1

i am trying to get an citrix application out of netscaler logs. below is a snippet of the log

  • applicationName Outlook 2010 - startTime "05/19/2016:16:04:21 " -

I am trying to get up until the " - " so i can parse it out but am having issues. the following regex test gives back the right results but in the trigger i keep getting null.any suggestions would be great!

var app = /applicationName ([^[:space:]]+[^-]+)/.exec(data);


#2

Looks like you’re trying to use a egrep regular expression, not a js regexp. Perhaps try this:

/applicationName\s*([^-]+)\s*-/

Translated:
“applicationName, zero or more spaces, followed by any non-dashes, zero or more spaces, and then a dash”.

Parens are located to capture just the application name (Outlook 2010 in your example.)


#3

That worked. Unfortunately in doing this i realized some of the applications have a " - " would there be a way to crab up until the “- startTime”


#4

Perhaps, this?

/applicationName\s*(.*)\s*-\sstartTime/

This will grab any character between “applicationName + [space]” and “- startTime”, including dashes, spaces, and other characters.


#5

You could try this one: https://regex101.com/r/nO2rL2/1
/applicationName ([^-]*) - ([^ ]*) "([^ ]*) " -/

This captures all the groups I assume you might want. It assumes the application name has no dashes “-”, the “startTime” token has no spaces, and the time value has no spaces to capture the right tokens. You could then use group[1] for application name, group[2] for the, I assume, startTime/endTime, and group[3] for the time value.


#6

that worked great! thank you!


#7

thank you dbenson, unfortunately some of the groups have a “-” in them so i had to go off the “startTime” part since thats the gap.