Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "Root"
- "Root"
- "Root(branch1/branch2) text(branch3/branch4)"
- ([^/()]*((?<=().*(?=)))[^/()]*)|([^/()]+)
- "Root(branch1/branch2)"
- "("
- Regex.Matches
- Regex.Matches
- (?<=^|/)((?<br>()|(?<-br>))|[^()])*?(?(br)(?!))(?=$|/)
- (?<=^(?(brb)(?!))(?:(?<-brb>()|(?<brb>))|[^()])*)
- /
- (?=(?:(?<bra>()|(?<-bra>))|[^()])*(?(bra)(?!))$)
- List<string> Tokenize(strInput)
- {
- var sb = new StringBuilder();
- var tokens = new List<string>();
- bool inParen = false;
- foreach(var c in strInput)
- {
- if (inParens)
- {
- if (c == ')')
- inParens = false;
- else
- sb.Append(c);
- }
- else if (c == '(')
- inParens = true;
- else if (c == '/')
- {
- tokens.Add(sb.ToString());
- sb.Length = 0;
- }
- else
- sb.Append(c);
- }
- if (sb.Length > 0)
- tokens.Add(sb.ToString());
- return tokens;
- }
- /((.+?)|[^/(]+)+/
- /
- ( # group things to be captured
- (.+?) # 1 or more of anything in (escaped) brackets, un-greedily
- | # or ...
- [^/(]+ # 1 or more, not slash, and not open bracket characters
- )+ # repeat until done...
- /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement