Ask a string matching problem, create {{A B}} {C} |, how to identify the "create

Ask a string matching problem,
If the string is:
create { { A | B} } { C }

With Ruby, how to identify the "create", "{{A|B}}" and "{C}" the three part?

Started by Jennie at November 15, 2016 - 6:42 AM

It seems not the regular processing problems.

Make sure, create {A}{b}
create{A|B}{sadasdasd}
The status of the acceptable is it right??

Posted by Avivahc at November 27, 2016 - 6:46 AM

[code=ruby][25] pry(main)> s="123123xyz{{a|b}}{c}"
=> "123123xyz{{a|b}}{c}"
[26] pry(main)> s.scan(/{+.*?}+|[^{}]+/)
=> ["123123xyz", "{{a|b}}", "{c}"]
[/code]

Posted by Steven at December 03, 2016 - 7:05 AM

To: s.scan(/{+.*?}+?|[^{}]+/)

Posted by Steven at December 05, 2016 - 7:26 AM