How can I split a string with qoutes, doubleqoutes and other metacharacters in REGEX?

thugster69

Active member
Joined
Jun 17, 2010
Messages
35
Programming Experience
Beginner
Hey guys,

For two days, already, I've been bugged by my problem. I'm trying to split a string of text i.e.( "Lakeside".) and store it like this:

myArray(0) = "
myArray(1) = L
myArray(2) = a
myArray(3) = k
myArray(4) = e
myArray(5) = s
myArray(0) = i
myArray(0) = d
myArray(0) = e
myArray(0) = "
myArray(0) = .

I'm currently using this REGEX
VB.NET:
Dim pattern As String = "(?=[a-zA-Z0-9 ^.+\._.\,\=\[\]\{\}])(?<!^)"
        
        myArraySolution = Regex.Split(""Lakeside".", pattern)

EDIT:
VB.NET:
Dim pattern As String = "(?=[a-zA-Z0-9 ^.+\'\._.\,\=\[\]\{\}])(?<!^)"
This pattern seems to make the splitting of QUOTES work!

But still, to no avail.. I can split other metacharacters but not quote and double quote.. Can you help me on this?
 
Last edited:
Why split to single chars? You can already access any char of a string like an array: theString(index). This is shorthand for accessing by default property Chars: theString.Chars(index)
 
Back
Top