Skip to content

Instantly share code, notes, and snippets.

@roalcantara
Created February 4, 2017 15:03
Show Gist options
  • Select an option

  • Save roalcantara/bb191aa621d74097c5645f1e4d598c72 to your computer and use it in GitHub Desktop.

Select an option

Save roalcantara/bb191aa621d74097c5645f1e4d598c72 to your computer and use it in GitHub Desktop.
Ruby: Removing tags with gsub and regex
str = '''
<input maxlength=\"1\" size=\"1\" onfocus=\"inputFieldFocus(this)\" onkeyup=\"autotab(this,1,event)\" class=\"screen_color_UNA screen_field \" value=\"\" name=\"IF_642\" type=\"text\"> 213.897.176
<input maxlength=\"1\" size=\"1\" onfocus=\"inputFieldFocus(this)\" onkeyup=\"autotab(this,1,event)\" class=\"screen_color_UNA screen_field \" value=\"\" name=\"IF_722\" type=\"text\"> 213.897.077
'''
str.gsub(/<input(.*?)"> /, '')
# => "\n213.897.176\n213.897.077\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment