How can I get the individual words contained only within {}
out of the text
an example of the text {Creating|Making|Producing} blah blah blah
or
another example of the text {{In order to|As a way to|So that you can|To be able to} {connect|link|join}} blah blah blah
I have got this far with my limited regex knowledge
text.scan(/{([^}]*)}/)[0][0].split('|')
but this selects the text {In order to|As a way to|So that you can|To be able to
and splits it like so {In order to
How can I select the text only within the {}
?
Expected output
["In order to", "As a way to", "So that you can", "To be able to"]
Thank you!
尝试:
text.scan(/{([^{}]*)}/)[0][0].split('|')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.