Skip to content

Instantly share code, notes, and snippets.

@richlv
Created October 28, 2015 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richlv/ff40e6460a696b1ca667 to your computer and use it in GitHub Desktop.
Save richlv/ff40e6460a696b1ca667 to your computer and use it in GitHub Desktop.
--- possible input :
key [t|a]
<style type="text/css"><!--/*--><![CDATA[/*><!--*/
key2[param] [u|1]
something else
key3[[param,param],param] [z|44]
--- desired output (validating trimmed $1 for something like [a-zA-Z0-9\[*] ):
key
key2[
key3[
--- reasoning :
key [t|a] <- [ present, no [ in $1, whole $1 taken
<style <![CDATA[/*><!--*/ <- $1 does not match
key2[param] [u|1] <- [ present on line and in $1, $1[ taken
something else <- no [ on the whole line
key3[[param,param],param] [z|44]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment