The regex

Y

yxq

I want to apply the regex below in vb.net
^([a-zA-Z]\:|\\\\[^\/\\:*?"<>|]+\\[^\/\\:*?"<>|]+)(\\[^\/\\:*?"<>|]+)+(\.[^\/\\:*?"<>|]+)$

The url
http://www.regexlib.com/REDetails.aspx?regexp_id=425

But vb.net said there are invalid chars.

Dim a As String = "m:\twxt\.exe"

'The code below invalid.....
Dim b As String =
"^([a-zA-Z]\:|\\\\[^\/\\:*?"<>|]+\\[^\/\\:*?"<>|]+)(\\[^\/\\:*?"<>|]+)+(\.[^\/\\:*?"<>|]+)$"

MessageBox.Show(Regex.IsMatch(a, b))


Thank you
 
K

Ken Tucker [MVP]

Hi,

To add a " to a string use "". Try this for you regular expression
pattern string.

Dim b As String =
"^([a-zA-Z]\:|\\\\[^\/\\:*?""<>|]+\\[^\/\\:*?""<>|]+)(\\[^\/\\:*?""<>|]+)+(\.[^\/\\:*?""<>|]+)$"



Ken
 
Y

yxq

Yes, thank you very much


Ken Tucker said:
Hi,

To add a " to a string use "". Try this for you regular expression
pattern string.

Dim b As String =
"^([a-zA-Z]\:|\\\\[^\/\\:*?""<>|]+\\[^\/\\:*?""<>|]+)(\\[^\/\\:*?""<>|]+)+(\.[^\/\\:*?""<>|]+)$"



Ken

----------------------------

yxq said:
I want to apply the regex below in vb.net
^([a-zA-Z]\:|\\\\[^\/\\:*?"<>|]+\\[^\/\\:*?"<>|]+)(\\[^\/\\:*?"<>|]+)+(\.[^\/\\:*?"<>|]+)$

The url
http://www.regexlib.com/REDetails.aspx?regexp_id=425

But vb.net said there are invalid chars.

Dim a As String = "m:\twxt\.exe"

'The code below invalid.....
Dim b As String =
"^([a-zA-Z]\:|\\\\[^\/\\:*?"<>|]+\\[^\/\\:*?"<>|]+)(\\[^\/\\:*?"<>|]+)+(\.[^\/\\:*?"<>|]+)$"

MessageBox.Show(Regex.IsMatch(a, b))


Thank you
 
Y

yxq

Can anyone change the regex below to match local folder(directory)?


yxq said:
Yes, thank you very much


Ken Tucker said:
Hi,

To add a " to a string use "". Try this for you regular expression
pattern string.

Dim b As String =
"^([a-zA-Z]\:|\\\\[^\/\\:*?""<>|]+\\[^\/\\:*?""<>|]+)(\\[^\/\\:*?""<>|]+)+(\.[^\/\\:*?""<>|]+)$"



Ken

----------------------------

yxq said:
I want to apply the regex below in vb.net
^([a-zA-Z]\:|\\\\[^\/\\:*?"<>|]+\\[^\/\\:*?"<>|]+)(\\[^\/\\:*?"<>|]+)+(\.[^\/\\:*?"<>|]+)$

The url
http://www.regexlib.com/REDetails.aspx?regexp_id=425

But vb.net said there are invalid chars.

Dim a As String = "m:\twxt\.exe"

'The code below invalid.....
Dim b As String =
"^([a-zA-Z]\:|\\\\[^\/\\:*?"<>|]+\\[^\/\\:*?"<>|]+)(\\[^\/\\:*?"<>|]+)+(\.[^\/\\:*?"<>|]+)$"

MessageBox.Show(Regex.IsMatch(a, b))


Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top