On Thu, 23 Feb 2006 14:30:10 +0000, Steve Flynn <[EMAIL PROTECTED]> wrote:
> >Speaking as somene who is learning RegExp's as he goes along I think; > >FOO = "[EMAIL PROTECTED]@$]{1,8}?\." > >At this point I think I've covered the first qualifier... An ungodly >mess if I ever saw one. Hope slips from my grasp as I realise I have >no way to say "and that can be followed by more of the same but only >as long as you don't roll over 44 characters and don't forget that you >can end in a period" > >As a little background, I'm writing an XML schema which is describing >an XML document which can contain MVS datasets in a few fields. I'm >trying to valididate fields and coming to the conclusion it's >exceptionally difficult for my limited experience. > I don't know anything about how RE's are used in XML schemas, but in Perl a RE could be used like this: while (<>) { chomp; if ($_ =~ '^[A-Z#$][A-Z0-9#$-]{0,7}([.][A-Z#$][A-Z0-9#$-]{0,7}){0,21}$' && length($_) <= 44) { print "passed: $_\n"; } else { print "failed: $_\n"; } } or in a shell script, egrep could use the same RE to check everything but the length. I left out checking for at-sign (@) because the list server might interpret parts of the RE as an email address and alter them, but just add an at-sign after each #$ in the RE. To allow lower case letters, change all 4 "A-Z" to "a-zA-Z" in the RE. If you don't want to accept the minus-sign, take out the minus signs in the two places where they are immediately followed by a square bracket. Bill Godfrey ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html