Skip to content

Instantly share code, notes, and snippets.

@kobi
Created July 28, 2010 20:04
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 kobi/496062 to your computer and use it in GitHub Desktop.
Save kobi/496062 to your computer and use it in GitHub Desktop.
# regex for http://stackoverflow.com/questions/3349999/net-regex-recursive-patterns
^(?:
(\w(?<Q>)) # Q1
|
(<(?<Angler>)) #Q2 - start <
|
(\>(?<-Angler>)(?<-A>)?(?<Q>)) #Q2 - end >, match Q
|
(\[(?<Block>)) # Q3 start - [
|
(;(?<Semi-Block>)(?<-A>)?) #Q3 - ; after [
|
(,(?<Comma-Semi>)(?<-Q>)*) #Q3 - , after ;
|
(\]((?<-Semi>)|(?<-Comma>))(?<-Q>)*(?<Q>)) #Q3 ] after ;, match Q
|
( ((,|(?<-Q>))*(?<A>)) ) #Match an A group
)*$
# Post Conditions
(?(Angler)(?!))
(?(Block)(?!))
(?(Semi)(?!))
(?(Comma)(?!))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment