Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

2 parts to a string find/replace issue

Hi all,

 

I want to see how I could achieve 2 things.

 

1.  Search and replace a string with blank for everything inside brackets including the brackets. e.g. 

    original text: articulate the interaction of ecology with human society, including policy and legal frameworks for management of biological resources (K, A, E, I)

   New Text: articulate the interaction of ecology with human society, including policy and legal frameworks for management of biological resources

 

2.  With that text inside the brackets, get it and put it into a new field.  This time not including brackets.

 

original

Field 1                                       Field 2

werwerwr (K,A,E,I)

 

original

Field 1                                       Field 2

werwerwr                                    K,A,E,I

 

 

Thanks in advance

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi,

 

    Please refer the screen shot below for job output.

0683p000009M0on.png

 0683p000009M0QJ.png

 

 

 

The transformations to be used are as below

 

For string first part ->     

row1.input_data.substring(0,row1.input_data.indexOf("(")) 

For string second part ->   

row1.input_data.substring(row1.input_data.indexOf("(")+1,row1.input_data.indexOf(")")) 

If the answer has helped you, could you please mark the topic as resolved? Kudos are also welcome 🙂

 

Warm Regards,

 

Nikhil Thampi

View solution in original post

4 Replies
Anonymous
Not applicable
Author

Hi,

 

    Please refer the screen shot below for job output.

0683p000009M0on.png

 0683p000009M0QJ.png

 

 

 

The transformations to be used are as below

 

For string first part ->     

row1.input_data.substring(0,row1.input_data.indexOf("(")) 

For string second part ->   

row1.input_data.substring(row1.input_data.indexOf("(")+1,row1.input_data.indexOf(")")) 

If the answer has helped you, could you please mark the topic as resolved? Kudos are also welcome 🙂

 

Warm Regards,

 

Nikhil Thampi

Anonymous
Not applicable
Author

Thanks Nikhil Thampi, worked a treat.

mani1304
Creator
Creator

 Thanks buddy, my requirement similar to this, except having some more conditions like below.

 

1) 6 fields separated by Pipe("|").

2) If the 5th field has values "R", then only 6 field is like "[123:11:xyz:00]", otherwise not.

 

Now, I need to first filter records using the above condition, which I am performing in tmap and separating the required 6 field after removing brackets, but now I want to separate this field(123:11:xyz:00) in the same tmap component having ":" separator and assign values to field1,field2,field3,field4 e.g. field1 would be 123, field2 would be 11, field3 would be xyz and field4 would be 00 and here I am stucking, can someone suggest on how to proceed on this. I only want to use one component( I think tmap should do the task).

I am new to Talend, earlier I was calculating this value in reformat component in ab initio after declaring variable and fetching the fields in vectors.

Thanks in advance.

zalibra
Contributor III
Contributor III

hi @nthampi 

 

if my input_data has a combination of values with parenthesis and without parenthesis, can you please provide what the command should be? for example, my input_data may contain the following:

1. abcdef (123)

2. hijklmn

3. wxyz (wxyz) (456)

 

i would want my output to be:

    field1                    field2

1. abcdef                 123

2. hijlkmn

3. wxyz (wxyz)         456