Venkat
Venkat

Reputation: 2579

How to split culture specific strings

I need to split the following string into string[].

string tempstring = "د.ع.‏123,456.00";// culture "ku-Arab-IQ"
string[] temp = tempstring.Split(".".ToCharArray());

But I am getting the following answer:

{string[4]}
    [0]: "د"
    [1]: "ع"
    [2]: "‏123,456"
    [3]: "00"

I expect the answer to be like:

{string[4]}

[0]: "‏123,456"
[1]: "00"
[2]: "د"
[3]: "ع"

Edit: But the above-mentioned splitting works fine for the string "123,456.00 د.ع.‏" (Culture - "ar-IQ") Result:

 {string[4]}
        [0]: "123,456"
        [1]: "00 د"
        [2]: "ع"
        [3]: "‏"

I think both of the strings are RTL text, but splitting results differ in both cases. Could you please help me, how to split this string properly. or whether this is the correct splitting.

Upvotes: 2

Views: 417

Answers (1)

Backs
Backs

Reputation: 24903

This string contains right to left substrings, so, you get correct result.

د is the first substring, because it's right to left,

ع is the second by the same reason

‏123,456 is usual left to right string, so it's third

00 is forth

Upvotes: 4

Related Questions