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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
RA6
Creator
Creator

Get part of filename - 3 last characters before extension file

Hello,

I need to retrieve the last 3 characters before the extension of some files:

Example:

18_08_2020_Client_GBP.txt

19_08_2020_Client_EUR.txt

18_08_2020_Client_MUR.txt

Expected output:

GBP

EUR

MUR

Any idea of of how can this be done please?

Many thanks.

Best regards,

Duke

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Try this in a tJava....

 

String value = "18_08_2020_Client_GBP.txt";

System.out.println(value.substring(value.lastIndexOf(".")-3, value.lastIndexOf(".")));

 

To use this you will either need to wrap it in a routine or simply use it in a tJavaRow/tJavaFlex. In a tJavaFlex, if your column holding the value is being connected via row1 and the column name is "value", the code would look like this.....

 

row2.country = row1.value.lastIndexOf(".")-3, row1.value.lastIndexOf("."));

 

Hope this helps

View solution in original post

1 Reply
Anonymous
Not applicable

Try this in a tJava....

 

String value = "18_08_2020_Client_GBP.txt";

System.out.println(value.substring(value.lastIndexOf(".")-3, value.lastIndexOf(".")));

 

To use this you will either need to wrap it in a routine or simply use it in a tJavaRow/tJavaFlex. In a tJavaFlex, if your column holding the value is being connected via row1 and the column name is "value", the code would look like this.....

 

row2.country = row1.value.lastIndexOf(".")-3, row1.value.lastIndexOf("."));

 

Hope this helps