Skip to content

Instantly share code, notes, and snippets.

@kumpelblase2
Created October 8, 2014 12:25
Show Gist options
  • Save kumpelblase2/49c38f93ca8339a9c33a to your computer and use it in GitHub Desktop.
Save kumpelblase2/49c38f93ca8339a9c33a to your computer and use it in GitHub Desktop.
This is a regex expression to parse the graphs given to us in an assignment
^([a-zA-Z0-9]+) ?(-(>|-) ?([a-zA-Z0-9]+) ?(\(([a-zA-Z0-9]+)\))?)? ?( ?: ?([0-9]+))?;$
This parses the following kinds of (undirectional) graphs:
a -> b;
a ->b;
a-> b;
a -- b;
b--a;
a -> b(my_name);
a -> b (my_name);
a -> b : 10;
a -> b:2020202;
a -> b (my_name) : 51;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment