A
anothermindbomb
Hello,
Brand new to RegExp's this afternoon, so forgive the mess I'm about to
present...
I've been trying to write a regular expression to validate an MVS
dataset name - a file, essentially, on an MVS mainframe. The naming
standards for datasets runs like this (straight from the IBM manual,
I'm afraid)...
A data set name can be one name segment, or a series of joined name
segments. Each name segment represents a level of qualification. For
example, the data set name DEPT58.SMITH.DATA3 is composed of three name
segments. The first name on the left is called the high-level
qualifier, the last is the low-level qualifier.
Each name segment (qualifier) is 1 to 8 characters, the first of which
must be alphabetic (A to Z) or national (# @ $). The remaining 7
characters are either alphabetic, numeric (0-9), national, or a hyphen
(-).
The period (.) separates name segments from each other. Including all
name segments and periods, the length of the data set name must not
exceed 44 characters. Thus, a maximum of 22 name segments can make up a
data set name.
So, SYS1.ISPPLIB is perfectly ok, 6TEST.FILE is bad (due to the leading
'6'), PROD.DATASET.D230206 is fine and TEST.QUALIFIED.DATASET is bad
(QUALIFIED > 8 characters)
So far, I've come up with a ^([A-Z#@\$]{1}[\w#@\$\-]{1,7})
^([A-Z#@\$]{1} / # deal with the first character being alpha or
national
[\w#@\$\-]{1,7}) # followed by up to 7 characters for the rest of
the first qualifier.
I now need to possibly match a period and then the rules for the first
qualifier all over again (hence the brackets in my existing regexp).
How do I do it?
If I code ^([A-Z#@\$]{1}[\w#@\$\-]{1,7})\. to match the period how can
I referback to the rule I've just written to say "and there may be some
more of this lot coming up"... I've been playing with "The RegExp
Coach" (http://weitz.de/files/regex-coach.exe) to experiment and test
my musings but when I attempt to code a \0 to refer to the capturing
group I've just made, it doesn't seem to do what I expect. I'm assuming
that's because what I'm expecting is utterly incorrect!
BTW, I'm not concerned about checking the length of the string I'm
matching being less than 44 characters (I don't know if that's even
possible in a regexp!) - I can do that outside of this bit of code.
I have a feeling that what I'm attempting to do isn't particularly
hard, but I'm struggling to make further progress after matching the
first part of my string... a prod in the right direction, rather than a
solution would be most welcome - I'd like to learn how to work this out
for myself rather than have someone present me with the answer.
Cheers,
Steve,.
Brand new to RegExp's this afternoon, so forgive the mess I'm about to
present...
I've been trying to write a regular expression to validate an MVS
dataset name - a file, essentially, on an MVS mainframe. The naming
standards for datasets runs like this (straight from the IBM manual,
I'm afraid)...
A data set name can be one name segment, or a series of joined name
segments. Each name segment represents a level of qualification. For
example, the data set name DEPT58.SMITH.DATA3 is composed of three name
segments. The first name on the left is called the high-level
qualifier, the last is the low-level qualifier.
Each name segment (qualifier) is 1 to 8 characters, the first of which
must be alphabetic (A to Z) or national (# @ $). The remaining 7
characters are either alphabetic, numeric (0-9), national, or a hyphen
(-).
The period (.) separates name segments from each other. Including all
name segments and periods, the length of the data set name must not
exceed 44 characters. Thus, a maximum of 22 name segments can make up a
data set name.
So, SYS1.ISPPLIB is perfectly ok, 6TEST.FILE is bad (due to the leading
'6'), PROD.DATASET.D230206 is fine and TEST.QUALIFIED.DATASET is bad
(QUALIFIED > 8 characters)
So far, I've come up with a ^([A-Z#@\$]{1}[\w#@\$\-]{1,7})
^([A-Z#@\$]{1} / # deal with the first character being alpha or
national
[\w#@\$\-]{1,7}) # followed by up to 7 characters for the rest of
the first qualifier.
I now need to possibly match a period and then the rules for the first
qualifier all over again (hence the brackets in my existing regexp).
How do I do it?
If I code ^([A-Z#@\$]{1}[\w#@\$\-]{1,7})\. to match the period how can
I referback to the rule I've just written to say "and there may be some
more of this lot coming up"... I've been playing with "The RegExp
Coach" (http://weitz.de/files/regex-coach.exe) to experiment and test
my musings but when I attempt to code a \0 to refer to the capturing
group I've just made, it doesn't seem to do what I expect. I'm assuming
that's because what I'm expecting is utterly incorrect!
BTW, I'm not concerned about checking the length of the string I'm
matching being less than 44 characters (I don't know if that's even
possible in a regexp!) - I can do that outside of this bit of code.
I have a feeling that what I'm attempting to do isn't particularly
hard, but I'm struggling to make further progress after matching the
first part of my string... a prod in the right direction, rather than a
solution would be most welcome - I'd like to learn how to work this out
for myself rather than have someone present me with the answer.
Cheers,
Steve,.