For example, if I have a value that equals 12345, mirroring it would produce 54321 and that would have to be combined together, into 1234554321, a new value. Is there a simple way of doing this type of operation in any of the languages that I have listed (I understand batch is not seen as a programming language).

  • In general, a string (ie: "12345") is just an array of characters. Loop backward through the array and put it into a new array, join the arrays. And if needed, convert back into a numeric value. – Ƭᴇcʜιᴇ007 Sep 19 '17 at 12:31
  • I know... but I don't know how to do it. Root had a nice explanation of how to do it in Powershell, so that is the type of answer I was looking for. – Henry Sep 19 '17 at 12:35
  • 3
    @MatthewC In many ways, Ƭᴇcʜιᴇ007's comment is more helpful. The SU community generally hopes that the requester posts at least some of their own code. This not only gives us a place to start helping, but also shows you've made an effort on your own before posting. – root Sep 19 '17 at 12:39
  • 1
    Then you should have posted at Stack Overflow, but only after investigating, as this is really just a straight "give me the codez" type question. – Ƭᴇcʜιᴇ007 Sep 19 '17 at 12:39
  • I understand that it's an educational environment, but I need to finish what I am doing by the next hour, and this was a stumbling block as I have very little programming experience. I will make sure to post differently in the future and spend more time investigating. – Henry Sep 19 '17 at 12:47

One way with Powershell:

# the original number
$left = '12345'

# the number reversed
$right = $left[-1..-($left.length)] -join “”

# join the original with the reverse
$together = "$left$right"

Powershell using regex:

$string = "12345"

$revert = ([regex]::Matches($String,'.','RightToLeft') | ForEach {$_.value}) -join ''

Write-Output "$string$revert"

Not the answer you're looking for? Browse other questions tagged or ask your own question.