Not having word more than 50 characters...

  • Thread starter Thread starter Amith Singh
  • Start date Start date
A

Amith Singh

Hello All,
I am using .Net Framework 1.1.
Using Regular Expressions I would like to split a word(inserting a blank
space) in a string if the word is more than N(say 50) characters. I can do
the same using string manipulations. I am just curious using regular
expressions it should be fast and less number of statements.
Thanks,
Amith
 
Regular Expressions is not particularly useful in this situation. It's
really a matter of building a new string by using Substring on the original,
and concatenating the portions together.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Kevin,
Why would you say regular expressions aren't particularly useful? I think
part of the problem is what's being done isn't well explained. This is the
3rd time Amith has asked and each time we get slightly more information. I
agree with you that if you have a single word in a string string x = "blah"
then substring makes sense. But I'm ASSuming that we are talking about
large text fields...in which case I think regular expressions are the right
way (maybe not the only one) to go...

Karl
 
Why would you say regular expressions aren't particularly useful?

I did say "in this situation." I use Regular Expressions "regularly."

However, if you think using Regular Expressions in this case is a good idea,
go ahead and post your solution. :)

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
I did in one of the previous threads Amith started asking the same question
:P

but here it is again:

Regex r = new Regex(@"(?<string>\S{50})", RegexOptions.Compiled
|RegexOptions.Multiline | RegexOptions.ExplicitCapture);
string newString = r.Replace(YOURSTRINGHERE, "${string} ");

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top