473,394 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Regular Expression Help please

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.

How might this be altered to avoid missing the last word?
Nov 21 '05 #1
5 1083

(?m:(?:(.)?){1,30}\s*?\n?){1,15}?
Nov 21 '05 #2
Thank you for the suggestion, but that actually ruins the word wrap by not
forcing breaks at whitespace.

Any other suggestions?

Anyone?

"" <a@b.com> wrote in message news:dD*****************@fe03.lga...
(?m:(?:(.)?){1,30}\s*?\n?){1,15}?

Nov 21 '05 #3

| Thank you for the suggestion, but that actually ruins the word wrap by not
| forcing breaks at whitespace.
|
| Any other suggestions?

perhaps if i knew more...are you splitting this with a regex or wanting
matches? you're just shooting for a way to do word wrapping, right?
Nov 21 '05 #4

| Any other suggestions?

sorry...i didn't look close enough at your regex...here's the fix:

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

it does NOT handle wrapping words...this one is the work horse and can be
used in conjunction with another to handle it.

good luck.
Nov 21 '05 #5
I'm not shooting for word wrapping -per se.

My users enter data into a multiline textbox that is 30 columns by 15 rows
(ASP.Net web form). As they are entering the data, the textbox presentation
wraps the input string for the user. When submitted, the value of the input
string is one long string (no line breaks unless the user purposefully added
a carriage return). I need to split this string into up to 15 strings, up
to 30 characters each because that is the format expected for downstream
processing by a legacy system. If I can acheive this, I'd like to use the
same string in a regular expression validator, to ensure that the user's
entry matches the pattern that can be split and sent to the legacy system.

Each match should terminate at a newline (if present) or whitespace (if
not), or at the end of the input string (default case). The exp I proposed
works well as long as the last character is whitespace. I need to modify
this (or choose another approach) to handle the last condition, (end of the
input string without whitespace terminator).

"" <a@b.com> wrote in message news:hF*****************@fe03.lga...
| Thank you for the suggestion, but that actually ruins the word wrap by not | forcing breaks at whitespace.
|
| Any other suggestions?

perhaps if i knew more...are you splitting this with a regex or wanting
matches? you're just shooting for a way to do word wrapping, right?

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
4
by: Buddy | last post by:
Can someone please show me how to create a regular expression to do the following My text is set to MyColumn{1, 100} Test I want a regular expression that sets the text to the following...
2
by: Brian Kitt | last post by:
I have a process where I do some minimal reformating on a TAB delimited document to prepare for DTS load. This process has been running fine, but I recently made a change. I have a Full Text...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
2
by: kieran | last post by:
Hi, I am using Visual Studio 2005 and am trying to use a Regular Expression Validator control. I have a drop down list which contains various names, the first one is "Please Select". I want...
3
by: Lucky | last post by:
hi guys, i'm practising regular expression. i've got one string and i want it to split in groups. i was trying to make one regular expression but i didn't successed. please help me guys. i'm...
3
by: Zach | last post by:
Hello, Please forgive if this is not the most appropriate newsgroup for this question. Unfortunately I didn't find a newsgroup specific to regular expressions. I have the following regular...
10
by: Mike9900 | last post by:
Hello, I need a regular expression to match a currency with its symbol, for example Pound66.99 must return 66.99 or Pound(66.99) or Pound-66.99 or -66.99Pound return -66.99 or any other...
1
by: sunil | last post by:
Hi, Am writing one C program for one of my module and facing one problem with the regular expression functions provided by the library libgen.h in solaris. In this library we are having two...
3
by: =?Utf-8?B?VEo=?= | last post by:
Hi, I want to know how Regular Expression can be used in this situation. I want to replace some string in specific condition.. The condition is to replace string only if the string is NOT inside...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.