|
-
Jul 13th, 2009, 06:43 PM
#1
Thread Starter
Lively Member
[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.
-
Jul 13th, 2009, 06:47 PM
#2
Re: Regex? Get content within " "
'hello' gets deleted because it's not in double quotes?
-
Jul 13th, 2009, 06:48 PM
#3
Thread Starter
Lively Member
Re: Regex? Get content within " "
-
Jul 13th, 2009, 08:40 PM
#4
Addicted Member
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)
-
Jul 13th, 2009, 09:20 PM
#5
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 \"
-
Jul 13th, 2009, 09:25 PM
#6
Addicted Member
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..
-
Jul 13th, 2009, 09:39 PM
#7
Thread Starter
Lively Member
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.
-
Jul 13th, 2009, 10:06 PM
#8
Addicted Member
Re: Regex? Get content within " "
Would this be more suited to your needs?
Code:
"[a-z \\]*"?[a-z \\]*"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|