Search:
Namespaces
Discussions
.NET v1.1
Feedback
Reg Expressions....
Messages
Related Types
This message was discovered on
microsoft.public.dotnet.framework.aspnet
.
Post a new message to this list...
Amith Singh
Hello All,
I would like to write a function which reads a string and adds one blank
space if any word is greater than 50 characters. How to write these kind of
functions using regular expressions.
Thanks,
Amith
Reply to this message...
Karl
Regex
r = new
Regex
(@"(?<string>\S{50,})",
RegexOptions
.Compiled |
RegexOptions
.Multiline |
RegexOptions
.ExplicitCapture);
string newString = r.Replace(YOURSTRINGHERE, "${string} ");
that should work.
karl
"Amith Singh" <
Click here to reveal e-mail address
> wrote in message
news:Op$
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
Lucas Tam
"Amith Singh" <
Click here to reveal e-mail address
> wrote in
news:Op$
Click here to reveal e-mail address
:
[Original message clipped]
Where do you want to place the blank space?
--
Lucas Tam (
Click here to reveal e-mail address
)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Reply to this message...
Karl
My example simply added a string to the word that had more than 50
characters
hello this is a veryveryvery... long string
would do -->
hello this is a veryveryvery...<SPACE> long string
But Lucas is right, the requirements weren't all that clear...
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Lucas Tam" <
Click here to reveal e-mail address
> wrote in message
news:Xns955D7DD28425nntprogerscom@140.99.99.130...
[Original message clipped]
Reply to this message...
Amith Singh
My requirement is, in a string if any word is more than 50 characetrs add
one blank space and continue with the rest of the string. To have a string
which do not have any word more than 50 characters. The idea is to split the
word.
Thanks,
Amith
"Lucas Tam" <
Click here to reveal e-mail address
> wrote in message
news:Xns955D7DD28425nntprogerscom@140.99.99.130...
[Original message clipped]
Reply to this message...
Karl
The code I gave almost does this, just get rid of the comma after the 50 -->
Regex
r = new
Regex
(@"(?<string>\S{50})",
RegexOptions
.Compiled |
RegexOptions
.Multiline |
RegexOptions
.ExplicitCapture);
string newString = r.Replace(YOURSTRINGHERE, "${string} ");
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Amith Singh" <
Click here to reveal e-mail address
> wrote in message
news:OF$
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
System.Text.RegularExpressions.Regex
System.Text.RegularExpressions.RegexOptions
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com