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
Post a Comment