Delimited Source - BeanShell - BuildMap Issue with \ slashes

This was originally a discussion here:

The problem is that one of the columns has the username formatted as DOMAIN\username - so in order to correlate I made a simple buildmap to remove the DOMAIN\ portion.

The catch is it doesn’t seem like Beanshell is properly processing the escaped \ and just getting mucked up somehow.

Un-escaped script

import sailpoint.connector.DelimitedFileConnector;

   Map map = DelimitedFileConnector.defaultBuildMap( cols, record );
   String columnUsername = (String) map.get( "Table0_Details3" );
   columnUsername = columnUsername.replaceAll("DOMAIN\", "");
   map.put("Table0_Details3",columnUsername);
   return map;

Escaped Script

import sailpoint.connector.DelimitedFileConnector;\r\n\r\n   Map map = DelimitedFileConnector.defaultBuildMap( cols, record );\r\n   String columnUsername = (String) map.get( \"Table0_Details3\" );\r\n   columnUsername = columnUsername.replaceAll(\"DOMAIN\\\", \"\");\r\n   map.put(\"Table0_Details3\",columnUsername);\r\n   return map;

This issue was resolved by the amazing Nithesh Rao in this post - BeanShell - BuildMap Replace Word - #10 by iam_nithesh

His summary was excellent in pointing out this was an age old issue with how Java handles the data.

This was my finished code escaped

import sailpoint.connector.DelimitedFileConnector;\r\n\r\n Map map = DelimitedFileConnector.defaultBuildMap( cols, record );\r\n String columnUsername = (String) map.get( \"Table0_Details3\" );\r\n columnUsername = columnUsername.replace(\"DOMAIN\\\\\", \"\");\r\n map.put(\"Table0_Details3\",columnUsername);\r\n return map;