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

Writing regular expression in tmap

Hi all,

 

How to write regular expression in tmap.

 

Source column data.

02 04OCT 10:48:16 220001 .

 

Output:

col1  col2      col3      col4

02,  04OCT,  10:48:16, 220001

 

Thanks

Shree

Labels (2)
20 Replies
Anonymous
Not applicable
Author

What about doing below?
col1=source_col.split(' ')[0]
col2=source_col.split(' ')[1]
col3=source_col.split(' ')[2]
and so on??
Anonymous
Not applicable
Author

Hi,

 

You could use tFileInputRegex or tExtractRegexFields components.

 

Eric

Anonymous
Not applicable
Author

Hi @eric44,

 

i have multiple columns for single file like that, i can't use single tFileInputRegex or tExtractRegexFields components if am correct.

 

Coulm1                                       column 2                    column 3

02 04OCT 10:48:16 220001 .     13:38:16 220001      220001 12OCT 2.4CR

 

i need to insert records single records to multiple columns based on regular expression in tmap or substr functions.

 

Thanks

Shree

Anonymous
Not applicable
Author

Hi @Chirgal,

 

i am getting error. PFA screen shot for references.

 

Thanks

Shree


screen shot.png
Anonymous
Not applicable
Author

Please use the below expression for splitting
source_col.split("\\s+")
Anonymous
Not applicable
Author

Hi @Chirgal,

I am facing error.

Source data for single column,
02 2OCT 10:57:37

Expected output:
col1 col2 col3
02 2OCT 10:57:37.  

PFA files.

 

And, Let me clear my requirement.

 

Source:

 

Coulm1                                              column 2                                             column 3
02 04OCT 10:48:16  220001 .   13:38:16 220001 220001                        12OCT 2.4CR

 

Output:

colu1  col2       col3           col4         col5          col6     col7       col 8       col9 

02         04OCT 10:48:16  220001 13:38:16  220001 220001   12OCT  2.4CR

 

Thanks

Shree


error.PNG
tmap.PNG
Anonymous
Not applicable
Author

Use below expression:
col1=source_col.split("\\s+")[0]
col2=source_col.split("\\s+")[1]

and so on
Anonymous
Not applicable
Author

Hi @Chirgal

 

Thanks, As per requirement is working fine.

 

But one issue i am facing. it not handling space or blank..

Source data for single column,
02 2OCT 10:57:37  <space> 20

02 2OCT 10:57:37     23        20

 

Current output:
col1 col2 col3        col4
02 2OCT 10:57:37. 20

02 2OCT 10:57:37  23 

 

Expected output:

col1 col2 col3             col4     col5
02 2OCT 10:57:37. <space> 20

02 2OCT 10:57:37     20        23 

 

i am attching two records for your references.

 

Thanks

Shree

 


saample.txt
Anonymous
Not applicable
Author

Use below expression 0683p000009MPcz.pngremove + sign)
col1=source_col.split("\\s")[0]
col2=source_col.split("\\s")[1]

and so on