Mirth Community

Mirth Community (http://www.mirthcorp.com/community/forums/index.php)
-   Support (http://www.mirthcorp.com/community/forums/forumdisplay.php?f=6)
-   -   Replace '\E' from URL link using replace method (http://www.mirthcorp.com/community/forums/showthread.php?t=218939)

shuhaibk54 02-13-2019 01:17 AM

Replace '\E' from URL link using replace method
 
var str='\E\\E\10.1.2.154\E\bcs\E\30877_P9999_Adult{2} _02_05_2019_0329p.pdf';
var res=str.replace('\E', '');
logger.debug(res);
---------------------------------------------------------------------
When I try run a script, it giving me an out put like :
--------------------Java script return like this --------------------
[2019-02-13 15:06:30,001] DEBUG (js-connector:?):

\E.1.2.154EcsE877_P9999_Adult{2}_02_05_2019_032 9p.pdf

---------------------------------------------------------------------
it does not get replaced . I am expecting final out like this
\\10.1.2.154\bcs\30877_P9999_Adult{2}_02_05_2019_0 329p.pdf



-----------------------------

Any quick advise on this

odo 02-13-2019 02:33 AM

You have to quote the backslash:
Code:

var str='\E\\E\10.1.2.154\E\bcs\E\30877_P9999_Adult{2}  _02_05_2019_0329p.pdf';
var res=str.replace(/\\E/g, '');
logger.debug(res);


shuhaibk54 02-13-2019 08:43 PM

I am getting output like : E.1.2.154EcsE877_P9999_Adult{2}_02_05_2019_0329 p.pdf

I am expecting output like : \\10.1.2.154\bcs\30877_P9999_Adult{2}_02_05_2019_0 329p.pdf


---------------------------------------
When I try on seperate java script latest version - its working fine with below code


var str=String.raw`\E\\E\10.1.2.154\E\bcs\E\30877_P999 9_Adult{2}_02_05_2019_0329p.pdf`;
var res=str.split(String.raw`\E`).join('');

console.log(res);

-----------------------------------------------------------------------------------
String.raw does not supported by mirth java script . Please advise

odo 02-14-2019 07:36 AM

Please try again, I edited my post above. The regex has to be javascript notation.

shuhaibk54 02-14-2019 07:30 PM

No luck this time too. :(
[2019-02-15 09:56:50,001] DEBUG (js-connector:?):
E .1.2.154E csE 877_P9999_Adult{2} _02_05_2019_0329p.pdf

I am getting as above.

agermano 02-15-2019 12:22 AM

Quote:

Originally Posted by odo (Post 265924)
You have to quote the backslash

You have to escape the backslash in the input string, too.
Code:

var str='\\E\\\\E\\10.1.2.154\\E\\bcs\\E\\30877_P9999_Adult{2}_02_05_2019_0329p.pdf';
var res=str.replace(/\\E\\/g, '\\');
logger.debug(res);



All times are GMT -8. The time now is 02:26 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation