Skip to content

Instantly share code, notes, and snippets.

Created August 8, 2016 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4aaafe28d507e3ea0fe6cd5279d51f6b to your computer and use it in GitHub Desktop.
Save anonymous/4aaafe28d507e3ea0fe6cd5279d51f6b to your computer and use it in GitHub Desktop.
def clean_up
if addr =~ /<macAddr>(.+)<\/macAddr>/
addr.replace $1
end
# more code
end
@lizard2010
Copy link

lizard2010 commented Aug 8, 2016

2.0.0-p247` :007 > a
 => "<macAddr>123</macAddr>" 
2.0.0-p247 :008 > a.scan(/<macAddr>([^<>]*)<\/macAddr>/imu).flatten
 => ["123"] 
2.0.0-p247 :009 > a = "<macAddr>123<\/notMatch>"
 => "<macAddr>123</notMatch>" 
2.0.0-p247 :010 > a.scan(/<macAddr>([^<>]*)<\/macAddr>/imu).flatten
 => [] 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment