
Signature
Happy coding!
Morten Wennevik [C# MVP]
I am not sure if I understand what you are asking me try. Nevertheless, I was
able to simplify the process by using Regex.
Regex exp = new Regex(@"\\\\|\n");
string [] finalText = exp.Split(textToParse);
Now with this in place, when I feed a text like:
We, \\parents, invite you
for the wedding of our son,
\\groom on \\date.
I get this:
We,
parents, invite you
for the wedding of our son,
groom on
date.
and what I want is:
We,
parents, invite you
for the wedding of our son,
groom
on <----------------------separate line
date.
Does anyone have any idea?
Thanks and regards,
Kumar
> Hi Kumar,
>
[quoted text clipped - 55 lines]
> > Regards,
> > Kumar
Morten Wennevik - 08 Jul 2005 21:20 GMT
Ok, I think I understand you now.
You want to take a regular text including linebreaks and if there is a keyword marked with \\ insert a linebreak before and after, unless one is already present.
I'm not aware of any simple way to do this, which doesn't mean there isn't one (I'm not too familiar with regex expressions). However, there shouldn't be much of a problem to do it manually. Loop through the file, if \\ is encountered, find the location of the next space or linebreak (which is \r\n in Windows, not just \n). If space is found, insert linebreak, if linebreak is found, continue.
> I am not sure if I understand what you are asking me try. Nevertheless, I was
> able to simplify the process by using Regex.
[quoted text clipped - 91 lines]
>> Happy coding!
>> Morten Wennevik [C# MVP]

Signature
Happy coding!
Morten Wennevik [C# MVP]
Raj Kumar - 13 Jul 2005 20:03 GMT
Thank you for your suggestions. With the help of another developer's
suggestions, I used Match method of Regex object and also used Replace method
of the string object and got it working.
Regards,
Kumar
> Ok, I think I understand you now.
>
[quoted text clipped - 97 lines]
> >> Happy coding!
> >> Morten Wennevik [C# MVP]