Advertisement

04.09.2008 at 07:13PM PDT, ID: 23310337
[x]
Attachment Details

cutting down a string with regex

Asked by attipa in Programming for ASP.NET, Microsoft Visual Basic.Net

Tags: ASP.NET, VB.NET

i have the following code:

HT_PostText = infoDS.Tables(0).Rows(x)(2).ToString()
Dim m As Match = Regex.Match(Regex.Replace(HT_PostText, "<.*?>", ""), "\W*((\w+(?:\W|$)+){0,14})(.*)")
If m.Groups("3").Value() = "" Then
    HT_Text.Text = m.Groups("1").Value()
Else
     HT_Text.Text = m.Groups("1").Value() & "..."
End If

It produces the following:  This is a test sentence which I don't want ...

I want the following:  This is a test sentence which I do want...

As you may see, the difference is that the "..." connects to the last letter without taking a space.  How can I make this happen?Start Free Trial
[+][-]04.09.2008 at 08:55PM PDT, ID: 21321564

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, Microsoft Visual Basic.Net
Tags: ASP.NET, VB.NET
Sign Up Now!
Solution Provided By: oxyoo
Participating Experts: 1
Solution Grade: A
 
 
[+][-]04.09.2008 at 09:30PM PDT, ID: 21321723

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628