Skip to content

Instantly share code, notes, and snippets.

@cehoffman
Created March 9, 2010 03:43
Show Gist options
  • Save cehoffman/326130 to your computer and use it in GitHub Desktop.
Save cehoffman/326130 to your computer and use it in GitHub Desktop.
RegExp.prototype.toString: () ->
flags: {
i: @ignoreCase
g: @global
m: @multiline
}
# Firefox 3 specific flag
flags.y = @sticky if @sticky?
[on_flags, off_flags]: ['', '']
for flag, status of flags
if status then on_flags += flag else off_flags += flag
"(?$on_flags${if off_flags.length > 0 then "-$off_flags" else ''}:$@source)"
puts /\d+/igm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment