Solved

Text formating

Posted on 1998-07-26
2
154 Views
Last Modified: 2010-03-05
How do i write a routine that allows me to wrap a long text i have in $txt into smaler parts, no longer than 80 Characters?

The routine will have to find the last space in the string that lies within the allowed line length, and then wrap the line there. Sounds easy, but i don't know how to do it!

So please, some one help me.

Martin.
0
Comment
Question by:freak022398
2 Comments
 
LVL 6

Accepted Solution

by:
alamo earned 70 total points
ID: 1208796
A routine? Surely you jest! Perl can do it in one line! :-)

The following line will wrap $txt each 80 characters, replacing a spce with \n.

$txt =~ s/(\G.{1,80}) /$1\n/g;

Hope this helps!
0
 

Author Comment

by:freak022398
ID: 1208797
And once again, thanks for a guick answer :)
The procedure think is an old Amiga habit :)

CYA. Martin.

0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question