Avatar of hankknight
hankknight
Flag for Canada

asked on 

ASP.NET / VB / REGEX: Before first word starting with lowercase

I want to put everything before the first word that starts with a lowercase letter inside <strong> tags.

Hello World 123 this is a test
Should become
Hello World 123 this is a test

Hello World 123 Testing
Should become
Hello World 123 Testing


Imports System.Web
Imports System.Data.SqlClient
Imports System.Data

Partial Class _format
Inherits System.Web.UI.Page

Protected Function AutoFormatText (ByVal input As String) As String

input = Server.HtmlEncode(input)

input = System.Text.RegularExpressions.Regex.Replace(input, "\(([^)]+)\)(?m[word that starts with lowercase]\r$|())", "<strong style=""color: red"">($1)</strong>")

return input
End Function

End Class

Open in new window

Regular ExpressionsVisual Basic.NET.NET Programming

Avatar of undefined
Last Comment
kaufmed

8/22/2022 - Mon