[RESOLVED] Regex? Get content within " "
I have a string that contains text similar to this:
Code:
hello "test" "another test\"" "ok"
I want it to split in an output like this:
Code:
test
another test\"
ok
In this thread http://www.vbforums.com/showthread.php?t=576158 (?<=[^\\]|^)"" was used to remove quotes that don't have a \ before them. Maybe it can be adapted to be used as a split? But I am unsure on how to do so.
Thanks in advance.
Re: Regex? Get content within " "
'hello' gets deleted because it's not in double quotes?
Re: Regex? Get content within " "
Re: Regex? Get content within " "
I'm not a genius with regexp, but this should work:
Although, you will have to remove the beginning and ending quotation marks:
Code:
String = String.Remove(0,1)
String = String.Remove(String.Length - 1, 1)
Re: Regex? Get content within " "
What happens if a string isn't terminated properly with double quotes? ie:
Code:
this is" just a "test" "example \"
Re: Regex? Get content within " "
Lol, didn't take that into consideration =P
There need to be clearer rules in case something like that occurs. Should it print:
" just a "test"
"example \"
Or should it just remove one of the quotation marks? Which one?
I.e.
"test"
"example \"
or
" just a test"
"example \"
etc..
Re: Regex? Get content within " "
If it is something like this:
"hello " hi"
You should get
hello
(with a space after hello) It should return the first set of double quotes.
If it is: "hello \" it should return: hello \
If that is even possible without making it extremely complicated while still being able to maintain:
"hello \" hi"
Being: hello \" hi
Otherwise if that is to complicated make it return nothing.
Re: Regex? Get content within " "
Would this be more suited to your needs?
Code:
"[a-z \\]*"?[a-z \\]*"