Remove some prefixes from the scope content

Hey together,

i have this string: " <xhtml super code=“”:pre-wrap;>{scope content}"
Now i want to remove everything before the {
How can I do this?
I tried using split but i did not work.
Please help me.


You could use a regular expression to grab everything inside the {}:

def grab_content(str)
  str.gsub(/\{(.*?)\}/, '\1')

Edit: This will only replace the {}. If the string contains anything before { or after }, that will still be present in the string.

If you want to just find the stuff inside, you can use #scan instead.

"this{scope content}that".scan(/\{(.*?)\}/)[0][0] # => "scope content"
1 Like