Skip to content

Instantly share code, notes, and snippets.

@error454
Created August 1, 2012 17:27
Show Gist options
  • Save error454/3229018 to your computer and use it in GitHub Desktop.
Save error454/3229018 to your computer and use it in GitHub Desktop.
QR Code WiFi Scheme Regex

QR Code WiFi Scheme Regexs of Extreme Awesomeness

A few regular expressions to parse WIFI schemes such as:

WIFI:T:WEP;S:test;P:rainbows\;unicorns\:jedis\,ninjas\\ secure;;

Network Type

###Raw (?<=T:)[a-zA-Z]+(?=;) ###expanded (?<=T:) #Match the prefix T: but exclude from capture [a-zA-Z]+ #Any alpha character, 1 or more repetitions (?=;) #Match the suffix ; but exclude from capture

SSID

###Characters that are not allowed

? " $ \ [ ] +

###Characters that must be escaped

\ ; , :

###Raw (?<=S:)((?:[^\;\?\"\$\[\\\]\+])|(?:\[\;,:]))+(?<!\;)(?=;)

###Java (?<=S:)((?:[^\\;\\?\\\"\\$\\[\\\\\\]\\+])|(?:\\[\\;,:]))+(?<!\\;)(?=;)

###expanded (?<=S:) #Match the prefix S: but exclude from capture ( #Choose from the following 2 choices (?:[^\;\?\"\$\[\\\]\+]) #Anything that isn't one of the restricted characters | #OR (?:\[\;,:]) #An escaped special character )+ #1 or more repititions (?<!\;)(?=;) #Match a ; only if there isn't a ; before it

Password

###Raw (?<=P:)((?:\[\;,:])|(?:[^;]))+(?<!\;)(?=;)

###Java (?<=P:)((?:\\[\\;,:])|(?:[^;]))+(?<!\\;)(?=;)

###expanded (?<=P:) #Match the prefix S: but exclude from capture ( #Choose from the following 2 choices (?:\[\;,:]) #An escaped special character | #OR (?:[^;]) #Any character that isn't a ; )+ #1 or more repititions (?<!\;)(?=;) #Match a ; only if there isn't a ; before it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment