Hail all ye Monkley monks,
I'm sure that this is a pretty straightforward question, but I've really only just started to get my feet wet with Regexp's and I'm fresh out of ideas.
I'm writing a script to release a number of emails from Quarantine. Essentially, the user is provided with a list of messages to release. I am trying to allow the user to enter a range of options, for example: 1,4-6,a. "1" would be release the first message, 4-6 would be messages "4-6" and "a" would release all messages. I am trying to write a regular expression that will eveluate a string of any length (i.e. with an infinite potential for message numbers) and ensures that it is in a valid format. Currently I am using the following peice of code which will only check if the first peice of data entered matches any of the expression given:
while ($releasing !~ /[0-9][0-9]?,?|[aA],?|[0-9][0-9]?\-[0-9][0-9]?,?/
print ("\n\nPlease type the numbers of the messages that are to be
+ released (n-n and n \nare allowable, A for all): ");
$releasing = <STDIN>;
I know that I could just accept the data, split it by comma and then evaluate each section, but I'd like to be able to continue prompting for the message selection then and there if the data entered is incorrect. For the record, I have tried using /^[0-9][0-9]?,?$|^[aA],?$|^[0-9][0-9]?\-[0-9][0-9]?,?$/
but that didn't help much either (only allowing one item entry). I have a feeling that I should be using /g and \G, but I can't really find a decent resource on the 'net to give me a good start at this.