re = /({})\1|[{]\s*?(\S*?|\S*?\(.*?\)|['][^']*?[']|["][^"]*?["]|["][^"]*?["]\.\(.*?\))(?:!(\S+?))?\s*?[}]/
str = '{0.concat("8a b c d e", 6)}
s df s sd{"one field name".toFixed(7 , 8)} kjnkj sd asdvs ds sd{0.concat("8a b c d e", 6)}
ascdac{ "one fieldname".toFixed(7 , 8) }
ascdac{ "onefi eldname" }
{onefieldname.toFixed(7 , 8)}
dfgsdg { "onefieldname".toFixed(7 , 8)}
{onefieldname: "toFixed(7 , 8)"}
{"onefieldname": "toFixed(7 , 8)"}
{ "onefiel dname" : "toFixed(7 , 8)"}
{ "onefiel dname": 8}
{ "onefiel dname" : {"onefi eldname".toFixed(7 , 8)} }
{ "onefiel dname" : {"onefi eldname".toFixed(7 , 8) }}
{ "onefiel dname" : {onefieldname.toFixed(7 , 8)} }
{ "onefiel dname" : { onefieldname.toFixed(7 , 8)} }'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html