CSV PropertyName to match up with logged User Agent

49 views
Skip to first unread message

Andy Wilbourn

unread,
May 26, 2017, 1:40:39 PM5/26/17
to browscap
I cannot seem to find how the pattern in the CSV file can be used to match up to a real User Agent logged. Forgive me if this a common question, but as I search I must not use the right terms to find it.

If I use the resource found on the site, http://browscap.org/ua-lookup I see my current browser:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36

Once looked up I see the results that come back and a REGEX version is available, but not in the CSV file. I presume some have able to use the CSV file and translate that to something like REGEX to pattern match. I want to leverage the CSV file to then understand what my audience base is using for devices.

So from the User Agent about I see I get the two different things back, is there not another file somewhere to have the exact same results to import to a DB?

browser_name_regex
/^mozilla\/5\.0 \(.*windows nt 10\.0.*win64. x64.*\) applewebkit.* \(.*khtml.*like.*gecko.*\) chrome\/58\..*safari\/.*$/

browser_name_pattern
mozilla/5.0 (*windows nt 10.0*win64? x64*) applewebkit* (*khtml*like*gecko*) chrome/58.*safari/*

Andy Wilbourn

unread,
May 26, 2017, 1:57:31 PM5/26/17
to browscap
I may have figure out the pattern to get the REGEX, I guess I should have looked closer, but this is what I have in a DAX expression using PowerBI Desktop.

regex = LOWER(
CONCATENATE(
CONCATENATE("/^"
,SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(browscap[PropertyName],"/","\/"), ".", "\."), "(", "\("), "*", ".*"), "?", "."), ")", "\)")
)
, "$/"))

James Titcumb

unread,
May 27, 2017, 7:28:34 AM5/27/17
to browscap
Hi Andy,

Sorry, I have no idea what a DAX expression or PowerBI Desktop is, but yes the match pattern is generic. Typically, our reference implementation, and third party implementations convert these to regular expressions.


Hope that helps!

Thanks
James
Reply all
Reply to author
Forward
0 new messages