Method: Parslet.match
- Defined in:
- lib/parslet.rb
.match(str) ⇒ Parslet::Atoms::Re
Returns an atom matching a character class. All regular expressions can be used, as long as they match only a single character at a time.
match('[ab]') # will match either 'a' or 'b'
match('[\n\s]') # will match newlines and spaces
There is also another (convenience) form of this method:
match['a-z'] # synonymous to match('[a-z]')
match['\n'] # synonymous to match('[\n]')
142 143 144 145 146 |
# File 'lib/parslet.rb', line 142 def match(str=nil) return DelayedMatchConstructor.new unless str return Atoms::Re.new(str) end |