Skip to content

Instantly share code, notes, and snippets.

@GeertJohan
Created February 11, 2013 08:21
Show Gist options
  • Save GeertJohan/4753228 to your computer and use it in GitHub Desktop.
Save GeertJohan/4753228 to your computer and use it in GitHub Desktop.
block-quotes code regexp for SGR (github.com/foize/go.sgr)
Regexp: `(?:(?:^\[?\[([a-zA-Z0-9\- ]+)\])|([.\n\r]+))*`
Input: "[red] blabla [[ escaped? [bla-fd] ]] escaped?"
Output(fmt %#v): []string{"[red]", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""}
Expected: []string{"[red]", " blabla [[ escaped? ", "[bla-fd]", " ]] escaped?"}
Regexp: \[([^\]]+)\]
Input: "[red] blabla [[ escaped? [bla-fd] ]] escaped?"
Output(fmt %#v): [][]int{[]int{0, 5}, []int{13, 33}}
Expected: [][]int{[]int{0,5}, []int{25, 8}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment