4

Reverse text line

 

Advanced

Reverse a line of text without the use of Array’s Reverse method, Array indices, Array notation, pipelines or loop statements.

Click the icons below for answer and explanation.


 


Winner: Rob Campbell

Filed in: Brainteasers Tags: 

4 Responses to "Reverse text line"

  1. dvswhoo says:

    Where is the answer? The buttons don’t work. It is probably some really dorky .NET thing that will do it. Although, there was a post over on stackoverflow.com about using regular expressions. How did “Rob Campbell” do it? If he even did…

    • oohwsvd says:

      ¬†Finally found the answer, search through the html to get it (I’m using Firefox 13.0.1 with win 7 32-bit)! Ha! I was on the right track with the regex stuff. gj kilroy

  2. nooB says:

    I found the explanation too simple. And the code too complex.
    Took me a while to figure out what was going on but I figured it out.
    The options are found here: http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regexoptions.aspx
    Final line of text: -join[regex]::Matches($str,”.”,’RightToLeft’)
    This was driving me a bit mad. Thx “Rob”.

  3. Yasutaka Ito says:

    I do not know why we need to complicate the solution by using RegEx, when there is a very simple way.

    $a = “Your text here.”
    -join $a[-1..-$text.Length]

    This solution is by PatrickS found at following web page.
    http://powershell.com/cs/blogs/tips/archive/2013/06/18/reversing-text-strings.aspx

Leave a Reply

Submit Comment

© 2016 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: