Regex question (upper/lower case)?

Worrow

Regular
Joined
Jul 10, 2003
Messages
68
How to do it with regex alone in vb.net? In my program, I have to call Ucase()/Lcase() to do the job(with regex.replace()). Is there any function under regex for the task?

Thanks in advance.
 
When you use the RegEx constructor, pass RegexOptions.IgnoreCase as a second parameter.
Visual Basic:
Dim re As New Regex("your pattern here", RegexOptions.IgnoreCase)
 
But how to change a string to upper/lower case by using regex alone?

Let's say I want to change "this is the day" to "This Is The Day". How to do it without calling ucase/lcase?
 
Not that I am aware of. If you are using VB.NET you can use the VB compatability function StrConv:
Visual Basic:
Dim properCase As String = StrConv("this is the day", VbStrConv.ProperCase)
However, this is rather bad programming practice, since StrConv is not supported by the CLR. Not only that, but it cannot be used from C#.

If you want to do it the proper way, you'll need to do it manually, I think.
 
I have checked out the examples regards to regex from the docs. They use either ucase/lcase or char.toupper/tolower to get it done.

Thanks for your suggestion.
 
Back
Top