Eorror in Regex

  • Thread starter Thread starter yxq
  • Start date Start date
Y

yxq

Imports System.Text.RegularExpressions

Dim objRegex As Regex
MessageBox.Show(objRegex.Split("C:\Test.txt", ":\")(0))

The error will occour, seem that the "\" can not become list separator.
If that will not work, how to separate using ":\"

Thank you
 
Hi,

\ is a special character in regular expressions. You need to
enclose the search in [\^ \].

MessageBox.Show(Regex.Split("C:\Test.txt", "[\^:\\]")(0))



Ken
 
Thank you very much


Ken Tucker said:
Hi,

\ is a special character in regular expressions. You need to
enclose the search in [\^ \].

MessageBox.Show(Regex.Split("C:\Test.txt", "[\^:\\]")(0))



Ken

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

yxq said:
Imports System.Text.RegularExpressions

Dim objRegex As Regex
MessageBox.Show(objRegex.Split("C:\Test.txt", ":\")(0))

The error will occour, seem that the "\" can not become list separator.
If that will not work, how to separate using ":\"

Thank you
 
Why "Regex.Split("\\", "[\^:\\]").Length = 3"




Ken Tucker said:
Hi,

\ is a special character in regular expressions. You need to
enclose the search in [\^ \].

MessageBox.Show(Regex.Split("C:\Test.txt", "[\^:\\]")(0))



Ken

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

yxq said:
Imports System.Text.RegularExpressions

Dim objRegex As Regex
MessageBox.Show(objRegex.Split("C:\Test.txt", ":\")(0))

The error will occour, seem that the "\" can not become list separator.
If that will not work, how to separate using ":\"

Thank you
 
yxq said:
Imports System.Text.RegularExpressions

Dim objRegex As Regex
MessageBox.Show(objRegex.Split("C:\Test.txt", ":\")(0))

The error will occour, seem that the "\" can not become list separator.
If that will not work, how to separate using ":\"

I am wondering why you do not use 'System.IO.Path.*' for this purpose.
 

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

Back
Top