Worrow Posted November 18, 2003 Posted November 18, 2003 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. Quote
*Experts* Volte Posted November 18, 2003 *Experts* Posted November 18, 2003 When you use the RegEx constructor, pass RegexOptions.IgnoreCase as a second parameter.Dim re As New Regex("your pattern here", RegexOptions.IgnoreCase) Quote
Worrow Posted November 18, 2003 Author Posted November 18, 2003 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? Quote
*Experts* Volte Posted November 18, 2003 *Experts* Posted November 18, 2003 Not that I am aware of. If you are using VB.NET you can use the VB compatability function StrConv: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. Quote
Worrow Posted November 19, 2003 Author Posted November 19, 2003 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.