ByulTaeng
ByulTaeng

Reputation: 1269

How to check if the input string is a valid VB string?

We know that VB string start and end with double quotes " "

So we have to use "" if we want " in VB string.

I wonder if there is a regular expression pattern which will match VB string?.

Upvotes: 1

Views: 1383

Answers (2)

Brian Rasmussen
Brian Rasmussen

Reputation: 116401

What is the context here? You only need to escape quotes to let the compiler distinguish between start/end quotes and quotes which are part of the string data. If the string is read during runtime there's no need for double quotes.

Upvotes: 0

JaredPar
JaredPar

Reputation: 754763

Are you trying to detect if the string they entered would be valid if typed into a VB code file? If so the following regular expression should do the trick

^"(("")|[^"])*"$

Upvotes: 1

Related Questions