Replace backslash


(Gavin) #1

Hi.

I have the following:

%globals_post_additionalInfo^unescapehtml^replace:\:\\%

Basically I’d like to replace \ with \ but I cant seem to find the magic pattern.
I have tried different numbers of \ on either side of the colon.

Any ideas ?

Thanks,
Gavin.


(Bart Banda) #2

Hi Gavin, what version of Matrix are you using?

Also, why do you need a replace keyword modifier to replace a character with the same character?


(Gavin) #3

5.5.3.3 - ah, looks like the post editor has messed around with my slashes.
I want to replace a single backslash with a double backslash.
It looks like I can use json_encode though - the only oddity being that also seems to replace some characters (like £) with unicode codes.


(Bart Banda) #4

Ah cool, that makes sense.

Try this replacement:

%globals_post_additionalInfo^asset_metadata_text^replace:([\\]+):\\\\%

Apparently there’s some buggy behaviour with backslashes and the replace keyword modifier in Matrix, especially when used with the colon character.

From our developer:

I think know why %asset_metadata_text^replace:\\:\\\% didn’t worked. it loos like teh argument char : is getting escaped due to \ preceding it. So basically the whole \\:\\\ is interpreted by modifier as the search regex (edited)


(Gavin) #5

Great - thanks for the update, I will give that a try