web stats
Replace '\E' from URL link using replace method - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 02-13-2019, 01:17 AM
shuhaibk54 shuhaibk54 is offline
Mirth Newb
 
Join Date: Jan 2018
Location: Abudhabi
Posts: 23
shuhaibk54 is on a distinguished road
Send a message via AIM to shuhaibk54 Send a message via Skype™ to shuhaibk54
Default 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
Reply With Quote
  #2  
Old 02-13-2019, 02:33 AM
odo odo is offline
OBX.3 Kenobi
 
Join Date: Feb 2017
Location: Luxembourg
Posts: 137
odo is on a distinguished road
Default

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);

Last edited by odo; 02-14-2019 at 07:34 AM. Reason: Oops, has to be javascript notation, of course...
Reply With Quote
  #3  
Old 02-13-2019, 08:43 PM
shuhaibk54 shuhaibk54 is offline
Mirth Newb
 
Join Date: Jan 2018
Location: Abudhabi
Posts: 23
shuhaibk54 is on a distinguished road
Send a message via AIM to shuhaibk54 Send a message via Skype™ to shuhaibk54
Default

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
Reply With Quote
  #4  
Old 02-14-2019, 07:36 AM
odo odo is offline
OBX.3 Kenobi
 
Join Date: Feb 2017
Location: Luxembourg
Posts: 137
odo is on a distinguished road
Default

Please try again, I edited my post above. The regex has to be javascript notation.
Reply With Quote
  #5  
Old 02-14-2019, 07:30 PM
shuhaibk54 shuhaibk54 is offline
Mirth Newb
 
Join Date: Jan 2018
Location: Abudhabi
Posts: 23
shuhaibk54 is on a distinguished road
Send a message via AIM to shuhaibk54 Send a message via Skype™ to shuhaibk54
Default

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.
Reply With Quote
  #6  
Old 02-15-2019, 12:22 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 747
agermano is on a distinguished road
Default

Quote:
Originally Posted by odo View Post
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);

Last edited by agermano; 02-15-2019 at 05:45 AM.
Reply With Quote
Reply

Tags
java, java script

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 09:41 PM.


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