string - c# split and reverse sentence with two languages -


i have sentence (in hebrew,rtl):

ואמר here אוראל

now, when insert array got:

  1. array[0] = אוראל
  2. array[1] = was
  3. array[2] = here
  4. array[3] = :ואמר

now, because hebrew rtl language need reverse english letters , need switch positions. notice need take care of sentence (which means can have more 2 english words).

how result following?

ואמר ereh saw אוראל

i thought maybe build time new string english words,reverse , build original string again, or maybe use in ref strings...


thanks helping still got problem! had splited sentence said,i reversed array , got this:

לארוא ereh saw רמאו

after step 2 postions of hebrew words worng! in step 3 reversed hebrew words again , got:

אוראל ereh saw ואמר

and need switch position(one in one, said can have sentence lot of words..) so, didn't understand how "put array string together"(step 5)

paolo did hard work of figuring out algorithm:

  1. split sentence array of strings
  2. reverse array
  3. if word not in hebrew reverse it
  4. join strings

here more elegant version using linq:

var result = sentence    .split(' ')    .reverse()    .select(w => ishebrew(w) ? w : new string(w.reverse().toarray())    .join(" ")  

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -