Page 1 of 1
Newbie: to find student ID#s
Posted: Tue Mar 04, 2008 10:25 am
by ptyrider
I need a regex to match 7-digit student ID numbers, presently from 4111509 to 5035465. The first number will always be 4 or 5. Sometimes the ID may have a hyphen after the third digit, like 503-5465. The numbers may not be surrounded spaces but may be more or less embedded in other strings, like "ID#5035465,short report." Thanks for any help. This is a one-off need and I hope you'll spare me the several hours needed to learn regex myself.
Re: Newbie: to find student ID#s
Posted: Tue Mar 04, 2008 10:30 am
by John Cartwright
I don't take into account everything, but heres a start
Re: Newbie: to find student ID#s
Posted: Tue Mar 04, 2008 9:02 pm
by ptyrider
Thanks. Unfortunately, that does not seem to work for me. This one that I did earlier does work except that it can't match numbers starting with 5 (but [4-5] rather than 4 at the beginning doesn't work; I don't really know what I'm doing!):
4[0-9]\d-\d{4}|4\d{6}
will match 4810638 or 481-0638, but not 5810638 or 581-0638
Re: Newbie: to find student ID#s
Posted: Wed Mar 05, 2008 5:14 am
by ptyrider
Ha! I tried again and this seems to work: [4-5][\d]\d-\d{4}|[4-5]\d{6}. Well this thread inspired more thought and eventual success. Thanks again.
Re: Newbie: to find student ID#s
Posted: Wed Mar 05, 2008 2:12 pm
by John Cartwright
ptyrider wrote:Well this thread inspired more thought and eventual success.
That is our goal here

Happy to hear you got it to work!
Re: Newbie: to find student ID#s
Posted: Sat Mar 08, 2008 6:45 pm
by Chris Corbyn