Newbie: to find student ID#s
Moderator: General Moderators
Newbie: to find student ID#s
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.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Newbie: to find student ID#s
I don't take into account everything, but heres a start
Code: Select all
!#*([4-5][\d-]{3,}+)!Re: Newbie: to find student ID#s
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
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
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.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Newbie: to find student ID#s
That is our goal hereptyrider wrote:Well this thread inspired more thought and eventual success.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Newbie: to find student ID#s
Code: Select all
/[45]\d{2}-?\d{4}/