Solved

vb.net regex with single and double quotes not working

Posted on 2015-02-19
3
195 Views
Last Modified: 2015-02-19
m_strRegEx = "^['"]*$"

' the double quote is detected
?Regex.IsMatch(chr(34), m_strRegEx)

' the double quote is not detected when other characters are assigned to the string
?Regex.IsMatch("a" & chr(34), m_strRegEx)

same problem with single quotes
why?
0
Comment
Question by:glenn_r
  • 2
3 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 40619856
Because the ^ says the string must have nothing before the quotes,
and the $ says the string must have nothing after the quotes.

The * also says that the string can have zero quotes.
0
 

Author Comment

by:glenn_r
ID: 40619882
so whats the test expression look like if i want to find out if the string contains single and/or double quotes?
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 40619890
Remove the ^, the $, and you probably want to remove the * too.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now