Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Regular expressions are very powerful, but their syntax can get large and archaic quickly. Irregular is a simple templating language for regular expressions. It helps you abstract chunks of your regular expressions into methods to help make them more readable.
irregular-rb is based on irregular-js.
class CatRegexp
include Irregular
def cat_names
names = ['betty', 'joyce', 'franklin', 'peter']
"(#{names.join '|'})"
end
end
irregular = CatRegexp.new
# insert results of method calls using backticks
regexp = irregular.compile_regexp(/I love my cat `cat_names`!/i)
p regexp # => /I love my cat (betty|joyce|franklin|peter)!/i
# use your regexp as normal
regexp =~ "I love my cat Joyce!" # => 0
Add this line to your application's Gemfile:
gem 'irregular'
And then execute:
$ bundle
Or install it yourself as:
$ gem install irregular
A module that provides functionality for compiling Irregular Expressions. Does nothing on its own; include or extend it into your class/module.
compile_regexp(regexp, options = 0)
compile_regexp(string, options = 0)
Method that compiles an irregular expression into a Regexp. (returns Regexp)
regexp
A regular expression to use the source pattern and options of for compilation.
string
A string to use as the source pattern for compilation.
options
A list or or-ed Regexp options to apply to the resulting Regexp.
If passed with a Regexp object, it will be or-ed against the Regexp's existing options.
Pull requests, bug reports welcome.
This library tries to mirror compilation behavior of irregular-js as much as possible- if you notice behavior you think might be a bug, test if it behaves the same in irregular-js first. If you still think it's a bug, the report should be filed against irregular-js, and then once it is resolved there, a bug report should be filed here.
Tests are written using Rspec. To run:
$ bundle install rspec spec
MIT
FAQs
Unknown package
We found that irregular demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.