I got a file with the following structure:
[section1]
item1 = text1
item2 = text2
item3 = text3
[section2]
item1 = text4
item2 = text5
item3 = text6
...
and i will find the section to a text. e.g. text is "text6" it should return "section2".
I t开发者_开发百科ied:
content.scan(/(^\[.*?\]).*?#{text}/m)
but that is only returning the first section of the file :/ (i use ruby)
/\[([^\[]*?)\][^\[]*?text6/m
This should work :)
精彩评论