Extract multiple strings enclosed in quotes in block of text

I have a paragraph of text in a string variable. Embedded in the text are multiple instances of strings enclosed by double quotes ("). For example:

I would like information on document “XYZ123” and also on part number “45678A”.

How could I extract the quoted strings into a string array? I’ve tried several regular expressions but I can’t seem to get it working.

Hi,

How about the following expression?

arrResult = System.Text.RegularExpressions.Regex.Matches(yourString,"""(.*?)""").Cast(Of System.Text.RegularExpressions.Match).Select(Function(m) m.Groups(1).Value).ToArray()

Regards,

@rleonen

Another way would be to use split activity and get all the odd indexed values

Str.Split({""""},StringSplitOptions.None).Where(function(x,i) Not (i mod 2).Equals(0)).ToArray

Hope this helps

Cheers

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.