0

How can I find a string between repeated strings? For example, if

string str = @"||AAA||BBB||CCC||";

how can I find all the strings(AAA, BBB, CCC) in order between repeated strings(||)?

5
  • 2
    With a regex... Commented Aug 8, 2017 at 16:57
  • @WillemVanOnsem I'm not that familiar with regular expressions, so would you please tell me how to? Commented Aug 8, 2017 at 16:58
  • msdn.microsoft.com/en-us/library/… Commented Aug 8, 2017 at 16:59
  • oh and does it also support unicodes? Commented Aug 8, 2017 at 17:00
  • @WillemVanOnsem Regex seems overkill for a simple string split don't you think? Commented Aug 8, 2017 at 17:21

1 Answer 1

4

Just use String.Split:

var str = @"||AAA||BBB||CCC||";
var splits = str.Split(new string[] {"||"}, StringSplitOptions.RemoveEmptyEntries);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.