Entering edit mode
10.3 years ago
Lee Katz
★
3.2k
Has anyone posted a regular expression for EC numbers? I think this should work but I'm not 100% sure.
/\(EC (\d+(\.n?[\d\-]+){3})\)/
I also found this other page but it doesn't actually post a comprehensive regular expression for ECs. http://www.enzyme-database.org/regex.php
I think that this regex implies that EC numbers can have fewer than four tiers, but if I run that regex, it is going to match against literally any number. Therefore maybe it should be changed from {0,3} to {3}:
And then to show that each site is either a dash or 1 or 2 digits (sorry, I don't have an example right now but I'm sure it exists for dashes)
How does that look? I took out the EC because I found examples in my text where EC doesn't exist.
Oh, the EC is optional in your data! Boy are we gonna wade through a bunch of false positives!
The diff between our regexes is that while mine matches the entire hierarchy, including the roots (like "EC2"), yours necessitates all levels in the hierarchy. But if the data has only full EC numbers, your Regex does the job better than mine.
I googled a bit but never encountered any EC number that used a '-', but it can surely be included.