GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - puneith/verbal: Make difficult regular expressions easy! Ruby port of the awesome VerbalExpressions repo - https://github.com/jehna/VerbalExpressions

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

32 Commits
32 Commits

Folders and files

NameName
Last commit message
Last commit date
lib
lib
 
 
spec
spec
 
 
.gitignore
.gitignore
 
 
.rspec
.rspec
 
 
.travis.yml
.travis.yml
 
 
.yardopts
.yardopts
 
 
Gemfile
Gemfile
 
 
Gemfile.lock
Gemfile.lock
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
Rakefile
Rakefile
 
 
VERSION
VERSION
 
 
verbal.gemspec
verbal.gemspec
 
 

Repository files navigation

Verbal

Build Status Gem Version

Overview

Verbal is a Ruby library that helps to construct difficult regular expressions. It's ported from the awesome JavaScript VerbalExpressions. Detailed documentation is available at rubydoc.

Getting started with the ruby gem.

Installation

$> gem install verbal
require 'verbal'

Examples

Here's a couple of simple examples to give an idea of how Verbal works:

Testing if we have a valid URL

# Create an example of how to test for correctly formed URLs
tester = Verbal.new do
  start_of_line
  find 'http'
  maybe 's'
  find '://'
  maybe 'www.'
  anything_but ' '
  end_of_line
end

# Create an example URL
test_url = "https://www.google.com"

# Use it just like a regular Ruby regex:
puts 'Hooray!  It works!' if tester.match(test_url)
puts 'This works too!' if tester =~ test_url

# Print the generated regex:
puts tester.source # => /^(?:http)(s)?(?::\/\/)(www\.)?([^\ ]*)$/i

Replacing strings

# Create a test string
replace_me = "Replace bird with a duck"

# Create an expression that seeks for word "bird"
expression = Verbal.new { find 'bird' }

# Execute the expression like a normal Regexp object
result = replace_me.gsub( expression, "duck" );

puts result # Outputs "Replace duck with a duck"

Capturing strings

# create expression
verbal = Verbal.new do
  capture { anything }
  find /\sby\s/
  capture { anything }
end
# match against test string
data = verbal.match('this is it by michael jackson')
puts data[1] # >> 'this is it'
puts data[2] # >> 'michael jackson'

Issues

  • I haven't yet ported the modifier code because Ruby Regexp handles modifiers a little differently.

Thanks!

Thank you to @jehna for coming up with the awesome original idea.

Thank you to @ryan-endacott for the original port.

About

Make difficult regular expressions easy! Ruby port of the awesome VerbalExpressions repo - https://github.com/jehna/VerbalExpressions

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.