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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Capture backslashes of string in tMap for delimited file output

I have a job where i am capturing two string fields into tMap. The first field is called fileInput_XML which is defined as a String. It holds an XML document in String format. The second field is called abs_path holds (String)globalMap.get("tFileList_1_CURRENT_FILEPATH") which is the filepath and filename of the xml document.  In tMap i am doing the following in an variable called var1 to add the abs_path into the fileInput_XML string value. 

 

StringHandling.EREPLACE(row1.fileInput_XML,"<head>", "<head><abs_path>" + row1.abs_path + "</abs_path>"

 

When I output the var1's content from tMap to tFileOutputDelimited the output has the filepath and filename details but the \ of the filepath is missing. In other words I was expecting the filepath  to be  C:\data\file1.xml  but the output file has the following C:datafile1.xml. 

 

How do i capture the backslashes in the output?

 

Appreciate your help. Thanks.

Labels (3)
1 Solution

Accepted Solutions
Jesperrekuh
Specialist
Specialist

String x="<x> <head/> </x>";
System.out.println(x);
String newx=StringHandling.EREPLACE(x, "\\<head/>","\\<head/>C\\:\\\\folder\\\\subfolder\\\\x.txt \\</head>");
System.out.println(newx);

Regex escaping... not just normal string escaping.

 

View solution in original post

3 Replies
Jesperrekuh
Specialist
Specialist

String x="<x> <head/> </x>";
System.out.println(x);
String newx=StringHandling.EREPLACE(x, "\\<head/>","\\<head/>C\\:\\\\folder\\\\subfolder\\\\x.txt \\</head>");
System.out.println(newx);

Regex escaping... not just normal string escaping.

 

vapukov
Master II
Master II

You can use on windows Linux style format for path:

0683p000009LxCk.png]

 

 

in this case all must work with You formula:

 

0683p000009LxCp.png

0683p000009LxCR.png

 

Anonymous
Not applicable
Author

Used the following in my Tmap Variable to overcome the problem. 

StringHandling.EREPLACE(row1.fileInput_XML,"<head>", "<head><abs_path>" + StringHandling.EREPLACE(row1.abs_path, "\\\\","\\\\\\\\") + "</abs_path>"   .  This help me get the following output <head> <abs_path> C:\data\file1.xml </abs_path></head>

 

Thanks for your pointer Dijke!