-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"

How can I find the |? and how can I find my pattern without spaces?

Dharman
  • 30,962
  • 25
  • 85
  • 135
user3132295
  • 288
  • 4
  • 23

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
  • 180,369
  • 20
  • 160
  • 215