HighTechTalks DotNet Forums  

Regular expression for word wrap?

Dotnet Scripting microsoft.public.dotnet.scripting


Discuss Regular expression for word wrap? in the Dotnet Scripting forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Kerry
 
Posts: n/a

Default Regular expression for word wrap? - 08-21-2005 , 10:40 PM






Please help.

I need a regular expression that parses a stream of up to 450 characters
into 15 separate strings of up to 30 characters each. The regex must break
at newlines. Ideally, the regex will "word wrap" that is, not break in the
middle of words. I have the following:

(?m?.)?){1,30}\s\n?){1,15}?

This works well as long as the user leaves at least one whitespace character
at the end. Without this, the last word is omitted from the match. I need
to use this in an ASP.Net webform to validate the user's entry to make sure
it can be split into no more than 15 lines, each no more than 30 characters.
Ideally, these splits will occur where the 30 column textbox wraps or where
the user forces a wrap by adding a carriage return.

How might this expression be altered to avoid missing the last word?




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.