Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/cless/cless.rb
Instance Method Summary collapse
Instance Method Details
#split_with_quotes(sep = '\s', q = '\'"') ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/cless/cless.rb', line 34 def split_with_quotes(sep = '\s', q = '\'"') r = / \G(?:^|[#{sep}]) # anchor the match (?: [#{q}]((?>[^#{q}]*)(?>""[^#{q}]*)*)[#{q}] # find quoted fields | # ... or ... ([^#{q}#{sep}]*) # unquoted fields )/x self.split(r).delete_if { |x| x.empty? } end |