Page 1 of 1

USING RULES Need help Overiding and stripping

Posted: Tue Aug 16, 2005 7:40 pm
by kommven
I am using QS.
I have a URGENT requirements to strip of all the characters after ':' and ';' including.
Any gurus to guide me...
thanks in advance
Kewl,

Posted: Wed Aug 17, 2005 5:18 pm
by kommven
No reply till now/...

Well I came up with a new requirement.
I need to strip away everything in parenthesis

Posted: Wed Aug 17, 2005 8:53 pm
by ray.wurlod
There is no such thing as URGENT here.

If you have DataStage it's very easy to pre-process your data. It's more tedious to do using QualityStage stages, but in general it's possible.

Do you have DataStage?

Posted: Thu Aug 18, 2005 1:46 pm
by kommven
Yes I can use DataStage whats the function that I can use?

Re: USING RULES Need help Overiding and stripping

Posted: Thu Aug 18, 2005 7:40 pm
by JamasE
kommven wrote:I have a URGENT requirements to strip of all the characters after ':' and ';' including.
Probably a lot easier in DS, but if you must use QS: Firstly, have ':' and ';' in your sep, but not strip lists.

Then a rule like

Code: Select all

:|**|$
RETYPE [1] 0
RETYPE [2] 0

;|**|$
RETYPE [1] 0
RETYPE [2] 0

**
COPY [1] {OP}
where OP is the variable reference where the output string will be stored.

(Note: Haven't pattern coded for a while, but I think this will work.)

Cheers,
Jamas

Posted: Thu Aug 18, 2005 7:42 pm
by JamasE
kommven wrote:I need to strip away everything in parenthesis
Again, probably easier outside QS, but...

Code: Select all

\(|**|\)
RETYPE [1] 0
RETYPE [2] 0
RETYPE [3] 0
And then either spit out the string or process elsewhere... (same warning as before re: coding)

Cheers,
Jamas

Posted: Fri Aug 19, 2005 3:04 am
by ray.wurlod
For removing everything between parentheses, and assuming there is only one set of parentheses, you can use an expression. If there is more than one set of parentheses, you need a routine that iteratively processes the string using the same logic for each set.
Extract everything up to and including the left parenthesis, then concatenate everything from and including the right parenthesis. You could use the field function, but Index() and Substring operations may be clearer. The following expression might appear in a server job Transformer stage.

Code: Select all

Left(TheString,Index(TheString, "(", 1)) : Right(TheString, Len(TheString)-Index(TheString, ")", 1) + 1)
Later in the same job, use a QualityStage stage in the DataStage job to invoke your other QualityStage processing job.

To strip all the characters following ":" or ";" similar expressions are used, for example

Code: Select all

Left(TheString, Index(TheString, ":", 1))