Skip to content

Program (based off Peter Norvig's code) to generate the shortest regular expression to match a mobile browser's User-Agent.

Notifications You must be signed in to change notification settings

angch/regexgolf-mobile-useragent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

regexgolf-mobile-useragent

regexgolf for mobile vs desktop browser's User-Agents

Program (based off Peter Norvig's code) to generate the shortest regular expression to match a mobile browser's User-Agent.

The shortest regular expression that can match a mobile browser's User-Agent, generated from two lists: one of known mobile user-agents, and one of known non-mobile user-agents.

Dataset based on available mobile browsers in Chrome's emulation: https://developer.chrome.com/devtools/docs/mobile-emulation

Code is hacked up version of Peter Norvig's Regular Expression golf program at http://nbviewer.ipython.org/url/norvig.com/ipython/xkcd1313-part2.ipynb?create=1

Spoiler:

  • Test for mobile user-agent: /u|an/i

  • Test for desktop user-agent: / i?.t/i

Online checker for the solution:

About

Program (based off Peter Norvig's code) to generate the shortest regular expression to match a mobile browser's User-Agent.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages