Pattern 0*Z

Infosphere's Quality Product

Moderators: chulett, rschirm

Post Reply
U
Participant
Posts: 230
Joined: Tue Apr 17, 2007 8:23 pm
Location: Singapore

Pattern 0*Z

Post by U »

In various name rule sets there is the pattern action as follows.

Code: Select all

; Remove delimiters
0*Z
RETYPE [1] 0
I understand that * is the floating position specifier and Z is the class for delimiters, but what does the 0 do in the pattern? I can't find any reference to a leading 0 in the Pattern Action reference manual.

I am guessing that it signifies "beginning of string" as in regular expressions, but can someone please confirm this?

And would it be better if this Pattern-Action included a REPEAT ?

Thank you for your time.
stuartjvnorton
Participant
Posts: 527
Joined: Thu Apr 19, 2007 1:25 am
Location: Melbourne

Post by stuartjvnorton »

That is the "repeat" available for retyping multiple tokens in one go. In this case, it removes all Z tokens in the string in question.

It is in the PAL reference (on page 41: "Retyping Multiple Tokens") from 8.7.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

As Stuart notes, the zero indicates the number of times the pattern-action is to be repeated. It must be followed immediately by an action that refers to operand [1].

So, in your example, the pattern is *Z (scan for the next class Z operand (delimiter)). If one is found, it will be operand [1] and the action RETYPE [1] 0 will cause that particular operand to have its class changed to the null class (0). The leading 0 tells QualityStage to repeat for all occurrences.

Yes, you (they) could have used REPEAT instead (page 50 of Pattern Action Reference manual). Most of us prefer the solution with the smaller number of keystrokes. :wink:

Code: Select all

*Z
RETYPE [1] 0
REPEAT
The leading number does not have to be zero. If it is a non-zero number, then QualityStage repeats that number of times. For example the following will retype just the first three delimiters.

Code: Select all

3*Z
RETYPE [1] 0
This facility is not available with the REPEAT action.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
U
Participant
Posts: 230
Joined: Tue Apr 17, 2007 8:23 pm
Location: Singapore

Post by U »

Thank you for those answers.
Post Reply