in reply to Re: Reversing Arabic String direction
in thread Reversing Arabic String direction

The question I had was how to handle things like "name21" or even "name_21". Both yours and my "solutions" have a problem with words like that. AppleFritter is on the right track, but I think this is the key consideration that will cause the most headaches.

You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.
  • Comment on Re^2: Reversing Arabic String direction

Replies are listed 'Best First'.
Re^3: Reversing Arabic String direction
by LanX (Saint) on Jul 10, 2014 at 22:03 UTC
    nope IMHO thats the way it should be in Arabic, if numbers were reversed:

    DB<115> join "", reverse map { /\d/ ? $_ : scalar reverse $_ } split + /(\d+)/, name_21 => "21_eman"

    But I didn't check your code...

    Cheers Rolf

    (addicted to the Perl Programming Language)

      Like I said, I took a brute-force approach. I'm not surprised at all (and expected) that a better, cleaner way would be apparent to one such as yourself. :)

      The code I provided will produce "21_eman" when given "name_21" as input. I think yours does the same (but I didn't test yours.) I have no idea what the correct way of dealing with that is.

      You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.
        > I have no idea what the correct way of dealing with that is.

        Arabic is right to left but numbers are written with the lowest digit first, thats why they are the same again (double reversed if you want)

        I suppose someone didn't know and encoded it wrong.

        update

        see example

        Cheers Rolf

        (addicted to the Perl Programming Language)