[Solved] How to matche all the words from a string that starts and ends with double underscore in rails [closed]


As @aspend mentioned above you will get result just by using .flatten property of array class:

<% str = "Hello my name is __john__ and i am __30__ years old"%>
<%=str.scan(/__(.*?)__/).flatten %>

Preview:
enter image description here

2

solved How to matche all the words from a string that starts and ends with double underscore in rails [closed]