Regex question (upper/lower case)?

Worrow

Well-known member
Joined
Jul 10, 2003
Messages
67
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.
Code:
Dim re As New Regex("your pattern here", RegexOptions.IgnoreCase)
 
But how to change a string to upper/lower case by using regex alone?

Lets 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:
Code:
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, youll 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.
 

Similar threads

E
Replies
0
Views
85
etl2016
E
I
Replies
0
Views
146
Innovators World Wide
I
S
Replies
0
Views
104
SSFFCC
S
W
Replies
0
Views
86
William A Wang
W
Back
Top