# How to replace back slash in CTL2

**URL:** https://forum.cloverdx.com/t/how-to-replace-back-slash-in-ctl2/1940
**Category:** CloverDX Platform
**Created:** [February 13, 2018, 12:00am UTC](https://forum.cloverdx.com/t/how-to-replace-back-slash-in-ctl2/1940 "2018-02-13T00:00:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mukunku](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@mukunku](https://forum.cloverdx.com/u/mukunku)
#### Post date: [February 13, 2018, 12:00am UTC](https://forum.cloverdx.com/t/how-to-replace-back-slash-in-ctl2/1940/1 "2018-02-13T00:00:00Z")

</div>

Hi,

I want to replace all back slashes with forward slashes and I have the following statement in my CTL2 code:

```auto
replace(myString, "\\", "/");

```

But I get this error:

> Invalid regular expression: “\”

So the interpreter thinks this is a regular expression when in fact it’s a string literal. Any way to work around this?

Thanks.

---

<div class="post-metadata">

### Author: ![Vladimir\_Barton](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.cloverdx.com/vladimir_barton/32/167_2.png) [@Vladimir\_Barton](https://forum.cloverdx.com/u/Vladimir_Barton)
#### Post date: [February 20, 2018, 9:36am UTC](https://forum.cloverdx.com/t/how-to-replace-back-slash-in-ctl2/1940/2 "2018-02-20T09:36:32Z")

</div>

Hi Mukunku,  
try changing your code to the following:

```auto
replace(myString, "\\\\", "/");

```

The reason why 4 backslashes are needed to reference one is that there are 2 levels of interpretation:

- At first, CloverETL interprets the “\\\\” string as 2 backslashes (each one escaped by a backslash).

- Then, the “\\” string is pushed to the ‘replace’ function as a regular expression. Note: the ‘replace’ function accepts regex expressions only as their second argument, more information can be found in our documentation). Similarly, “\\” is interpreted as “\” in regex (the backslash needs to be escaped by a backslash). More information can be found here.

Kind regards,
