ruby - Regular expression to fetch the value within all the " " -


a='fdkfjsdflksdj lfkjdflksdjf["fdkljfdfl"]fkjdfldjkf["fdfdf"]dfdfsdfsdfsdfddfdfkdfj["fdfds"]fdfasdfds' 

i need fetch values inside "" means out put should

fdkljfdfl fdfdf fdfds 

i have written below coding

puts a[/\["(.*)"\]/m] 

but returns

["fdkljfdfl"]fkjdfldjkf["fdfdf"]dfdfsdfsdfsdfddfdfkdfj["fdfds"] 

can me take particular string within ""

puts a.scan(/\["(.*?)"\]/m)                ^^ 

make regex non greedy.or use negation based regex.

puts a.scan(/\["([^"]*)"\]/m) 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -