Alale sa Alale sa - 9 months ago 40
C# Question

Replace in strings which contain Persian and English letters together in C#

This is the string :


I want to replace it, base on this structure:

if (str.Contains("[@PEYear]"))
str = str.Replace("[@PEYear]", "1393");
if (str.Contains("[@POOL]"))
str = str.Replace("[@POOL]", "7");

The result is : 1393/ف/7

But I need : 1393 then ف and then 7 (even I can't type it here :P)

How can I do this?

Answer Source

I don't know if this solution would be acceptable to you, but it works if you insert a left-to-right mark:

var str = "[@PEYear]/ف\u200E/[@POOL]";

This will force the rest of the string to be left-to-right.