-1

I have the following text

"a|mother" "b|father"

I want to find via Regex, groups of text that starts with '"' and ends with '"' and separate with '|' without spaces. Meaning the results would be:

  1. "a|mother"
  2. "b|father"

I try to use other posts to solve my question but still with no luck how can I find the |? and how can I find my pattern without spaces?

user3132295
  • 278
  • 4
  • 18

1 Answers1

1

Something like this:

  String source = "\"a|mother\" \"b|father\"";

  var result = Regex
    .Matches(source, "\"[^\"]*[^ ]\\|[^ ][^\"]*\"")
    .OfType<Match>();

  Console.Write(String.Join(Environment.NewLine, result));

Output is

"a|mother"
"b|father"
Dmitry Bychenko
  • 165,109
  • 17
  • 150
  • 199