DSXchange: DataStage and IBM Websphere Data Integration Forum
View next topic
View previous topic
Add To Favorites
This topic has been marked "Resolved."
Author Message
igorbmartins
Participant



Joined: 17 Mar 2008
Posts: 161

Points: 2183

Post Posted: Fri Jun 17, 2016 12:53 pm Reply with quote    Back to top    

DataStage® Release: 11x
Job Type: Parallel
OS: Unix
Hi guys,
I am trying to create a Standardization Rules, but I am facing some problems. The objective is to pick up the text between the brackets [] only if is in the end of the string such as:

• LIGACLIP CLIP TIT M BRANCO [200]
• CATETER ELETRODO BIPOLAR 5F S/BALAO [022-245M]
• MINI PLACA EM T 5 FUROS 1.2MM [10-050-01]

To these examples, I created this rules:
*& | \[ | & | \] | $ ;LIGACLIP CLIP TIT M BRANCO[200]
COPY [3] {CodRef}
RETYPE [2] 0
RETYPE [3] 0
RETYPE [4] 0

*& | \[ | & | - | & | \] | $ [{CodigoRef} = ""] ;CATETER ELETRODO BIPOLAR 5F S/BALAO[022-245M]
COPY [3] {CodigoRef}
CONCAT [4] {CodigoRef}
CONCAT [5] {CodigoRef}
RETYPE [2] 0
RETYPE [3] 0
RETYPE [4] 0
RETYPE [5] 0
RETYPE [6] 0

*& | \[ | & | - | & | - | & | \] | $ [{CodigoRef} = ""] ;MINI PLACA EM T 5 FUROS 1.2MM [10-050-01]
COPY [3] {CodigoRef}
CONCAT [4] {CodigoRef}
CONCAT [5] {CodigoRef}
CONCAT [6] {CodigoRef}
CONCAT [7] {CodigoRef}
RETYPE [2] 0
RETYPE [3] 0
RETYPE [4] 0
RETYPE [5] 0
RETYPE [6] 0
RETYPE [7] 0
RETYPE [8] 0

But there is some examples that I didn’t know how to pick up the text between the brackets such as:
• AREJADOR T2 FEMEA ARTICULADO [CPD 07125]

In addition it is possible to create a general rule to do this, I mean, I always want the text between the brackets no matter the pattern or the text.

To complicate a little more, sometimes the text has { or ( instead [ and in some cases the user mixed more than one character such as:

• Bla bla {home]
• Bla bla [home}

It is possible to solve this with a single rule or I need to create N rules?

Thanks,
Igor Bastos Martins
UCDI



Group memberships:
Premium Members

Joined: 21 Mar 2016
Posts: 335

Points: 3391

Post Posted: Fri Jun 17, 2016 1:57 pm Reply with quote    Back to top    

need more info...

Is it possible to have nested mixed punctuation like blah (other] blah [oops) or do they all match a simple pattern? Can they end with {[( ? or the like?

You should be able to make a single rule that says anything followed by one character in the list of {{( followed by (anything? a pattern? what makes sense here) and ends in one character from the list of ]})

That may not be sufficient for all cases or may even fail on some cases depending on the actual data patterns.

Then you need to replace {{( with [ and the same for ] maybe ?? or extract from there the portion you wanted?

The real catch is just whether the simple rule is sufficient for your data.


--- Some tasks may or may not make sense to do other ways. If I wanted the data in between two brackets, I would pull it out in a transformer.
Rate this response:  
Not yet rated
ray.wurlod

Premium Poster
Participant

Group memberships:
Premium Members, Inner Circle, Australia Usergroup, Server to Parallel Transition Group

Joined: 23 Oct 2002
Posts: 54287
Location: Sydney, Australia
Points: 294450

Post Posted: Fri Jun 17, 2016 9:18 pm Reply with quote    Back to top    

Try the pattern \[**\]$

_________________
RXP Services Ltd
Melbourne | Canberra | Sydney | Hong Kong | Hobart | Brisbane
currently hiring: Canberra, Sydney and Melbourne
Rate this response:  
Not yet rated
igorbmartins
Participant



Joined: 17 Mar 2008
Posts: 161

Points: 2183

Post Posted: Mon Jun 20, 2016 8:34 am Reply with quote    Back to top    

Hello, on the weekend I didiscovered how to do it in a single rule.

*& | & ="[", "(", "{" | ** | & ="]",")","}" | $ ;LIGACLIP CLIP TIT M BRANCO[200]
COPY [3] {CodigoRef}
RETYPE [2] 0
RETYPE [3] 0
RETYPE [4] 0

Thank you guys.
Rate this response:  
Not yet rated
ray.wurlod

Premium Poster
Participant

Group memberships:
Premium Members, Inner Circle, Australia Usergroup, Server to Parallel Transition Group

Joined: 23 Oct 2002
Posts: 54287
Location: Sydney, Australia
Points: 294450

Post Posted: Mon Jun 20, 2016 3:52 pm Reply with quote    Back to top    

Thank you for posting complete solution. Note that yours will pick up **[text) for example (mismatched brackets). But if you are 100% sure that the brackets will always be matched, then ...

_________________
RXP Services Ltd
Melbourne | Canberra | Sydney | Hong Kong | Hobart | Brisbane
currently hiring: Canberra, Sydney and Melbourne
Rate this response:  
Not yet rated
igorbmartins
Participant



Joined: 17 Mar 2008
Posts: 161

Points: 2183

Post Posted: Tue Jun 21, 2016 10:26 am Reply with quote    Back to top    

Hello Ray, because of that I decided to use this rule. In my data base there are rows with:

bla bla [0001]
bla bla {0002}
bla bla (0003)
bla bla [0004}
bla bla [0005)
bla bla {0006)

Thanks,
Igor Bastos Martins
Rate this response:  
Not yet rated
ray.wurlod

Premium Poster
Participant

Group memberships:
Premium Members, Inner Circle, Australia Usergroup, Server to Parallel Transition Group

Joined: 23 Oct 2002
Posts: 54287
Location: Sydney, Australia
Points: 294450

Post Posted: Tue Jun 21, 2016 4:01 pm Reply with quote    Back to top    

Given that such is the case, your rule is the perfect choice.

_________________
RXP Services Ltd
Melbourne | Canberra | Sydney | Hong Kong | Hobart | Brisbane
currently hiring: Canberra, Sydney and Melbourne
Rate this response:  
Not yet rated
Display posts from previous:       

Add To Favorites
View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2002 phpBB Group
Theme & Graphics by Daz :: Portal by Smartor
All times are GMT - 6 Hours