![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Is there an easy way to wrap text I'm programatically building some text. I end up with a string of about 1000 - 5000 characters. When I'm done I need to break it into an array of strings, each with 80 chars or less. This is supposed to be readable when I'm done so I can't just chop it into 80 char sections. Is there a function that does this or at least one that makes it easy? Thanks |
My System Specs![]() |
| | #2 (permalink) | ||||||||||||
| Guest | Re: Is there an easy way to wrap text RickB wrote:
http://www.microsoft.com/technet/scr.../apssol06.mspx Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com | ||||||||||||
My System Specs![]() | |||||||||||||
| | #3 (permalink) | ||||||||||||
| Guest | RE: Is there an easy way to wrap text Lets start by building our string PS> $str = "abcd" + "," + "efgh" + "," + "ijkl" + "," + "mnopq" + "," + "rstu" + "," + "vwxyz" PS> $str abcd,efgh,ijkl,mnopq,rstu,vwxyz I'm using , as a delimiter between the sections i.e. I will be splitting this string at the commas. The delimter could be any character(s) even a space - as long as you know it form part of any of your data sections We can then create an array by using the Spilt() method giving the delimiter you want to use PS> $array = $str.Split(",") PS> $array abcd efgh ijkl mnopq rstu vwxyz If you have the PowerShell V2 CTP you could use the -split operator instead PS> $array2 = $str -split "," PS> $array2 abcd efgh ijkl mnopq rstu vwxyz -- Richard Siddaway All scripts are supplied "as is" and with no warranty PowerShell MVP Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "RickB" wrote:
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||
| Guest | RE: Is there an easy way to wrap text Thinking about there is another alternative. Create an empty array PS> $array3 = @() In your program add the text directly into the array e.g. PS> $array3 += "abcd" PS> $array3 += "efgh" PS> $array3 += "ijkl" PS> $array3 += "mnopq" PS> $array3 += "rstu" PS> $array3 += "vwxyz" Then its alreday for you and you saving the string building and splitting effort PS> $array3 abcd efgh ijkl mnopq rstu vwxyz PS> -- Richard Siddaway All scripts are supplied "as is" and with no warranty PowerShell MVP Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "RichS [MVP]" wrote:
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #5 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: Is there an easy way to wrap text On May 23, 1:21*pm, "Marco Shaw [MVP]" <marco.shaw@_NO_SPAM_gmail.com> wrote:
I'll probably tweak it Tuesday it to split text (like qualified file or table names) that might otherwise overflow my 80 column limit because they don't contain spaces. The other stuff at that link will probably be interesting too. Maybe I'll have time to browse. Thanks. | ||||||||||||||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||||||||||||||
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Word Wrap in Hotmail | Marc Seidler | Live Mail | 2 | 04-10-2008 08:06 AM |
| Screen Wrap | Fred | Vista General | 1 | 03-04-2008 02:38 PM |
| running large PS commands text wrap | Mike Bonvie | PowerShell | 11 | 01-21-2008 11:00 PM |
| Word wrap | John Barnes | Vista General | 7 | 10-08-2007 10:14 AM |
| word-wrap | Thomas | PowerShell | 8 | 12-06-2006 07:03 PM |