Hi,
I need to extract a substring from a string.
For example:
'FAS960C' should be converted to 'FAS960'
'FAS960HC' should be converted to 'FAS960'
Requirement: Once there is a transition from numeric to character, then we are going to stop the search and provide result till that poistion.
Please help how to do it.
Thanks,
Nasimul
Extract substring from a string
Moderators: chulett, rschirm, roy
Nasimul,
that is an interesting question - I can't think of an easy way to do this in PX as there are no regular expression functions. The cheap way (which I wouldn't recommend) is to call a BASIC transform where this type of pattern matching can be done easily.
Can you specify the rule differently, i.e. "everything to the left of the first '9' in the string"? What is the maximum length of the string? One could use stagevars to
This is rather inefficient and if you have c++ skills then this would be a great place to write a buildop.
that is an interesting question - I can't think of an easy way to do this in PX as there are no regular expression functions. The cheap way (which I wouldn't recommend) is to call a BASIC transform where this type of pattern matching can be done easily.
Can you specify the rule differently, i.e. "everything to the left of the first '9' in the string"? What is the maximum length of the string? One could use stagevars to
Code: Select all
IF INDEX(In.String,"0")THEN INDEX(In.String,"0") ELSE 9999
IF INDEX(In.String,"1")THEN INDEX(In.String,"1") ELSE 9999
IF INDEX(In.String,"2")THEN INDEX(In.String,"2") ELSE 9999
IF INDEX(In.String,"3")THEN INDEX(In.String,"3") ELSE 9999
IF INDEX(In.String,"4")THEN INDEX(In.String,"4") ELSE 9999
IF INDEX(In.String,"5")THEN INDEX(In.String,"5") ELSE 9999
IF INDEX(In.String,"6")THEN INDEX(In.String,"6") ELSE 9999
IF INDEX(In.String,"7")THEN INDEX(In.String,"7") ELSE 9999
IF INDEX(In.String,"8")THEN INDEX(In.String,"8") ELSE 9999
IF INDEX(In.String,"9")THEN INDEX(In.String,"9") ELSE 9999
FirstNumPos = MIN(MIN(MIN(Pos0,Pos1),MIN(Pos2,Pos3)),MIN(Pos4,Pos5))...
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You could use an External Filter stage and process your string through, say, awk. This can handle regular expressions.
In BASIC you could use MatchField() functions.
In BASIC you could use MatchField() functions.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 301
- Joined: Thu Jul 14, 2005 10:27 am
- Location: Melbourne, Australia
- Contact:
Although you could add your own regular expression support using the C-source I posted <a href="viewtopic.php?t=107882"> here</a>.ArndW wrote:that is an interesting question - I can't think of an easy way to do this in PX as there are no regular expression functions.
J.
<b>John McKeever</b>
Data Migrators
<b><a href="https://www.mettleci.com">MettleCI</a> - DevOps for DataStage</b>
<a href="http://www.datamigrators.com/"><img src="https://www.datamigrators.com/assets/im ... l.png"></a>
Data Migrators
<b><a href="https://www.mettleci.com">MettleCI</a> - DevOps for DataStage</b>
<a href="http://www.datamigrators.com/"><img src="https://www.datamigrators.com/assets/im ... l.png"></a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: