I want to match the first number/word/string in quotation marks/list in the input with Regex. For example, it should match those:
"hello world" gdfigjfoj sogjds
-14.5 fdhdfdfi dfjgdlf
test14 hfghdf hjgfjd
(a (c b 7)) (3 4) "hi"
Any ideas to a regex or how can I start?
Thank you.
If you want to match balanced parenthesis, regex is not the right tool for the job. Some regex implementations do facilitate recursive pattern matching (PHP and Perl, that I know of), but AFAIK, C# cannot do that (EDIT: see Steve’s comment below: .NET can do this as well, after all).
You can match up to a certain depth using regex, but that very quickly explodes in your face. For example, this:
meaning
will match single nested parenthesis like
(a (c b 7))and(a (x) b (y) c (z) d), but will fail to match(a(b(c))).