Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • *Experts*
Posted
When you use the RegEx constructor, pass RegexOptions.IgnoreCase as a second parameter.
Dim re As New Regex("your pattern here", RegexOptions.IgnoreCase)

Posted

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?

  • *Experts*
Posted

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.

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...