{"id":13747525,"url":"https://github.com/ryan-endacott/verbal_expressions","last_synced_at":"2025-05-09T08:33:23.023Z","repository":{"id":427609,"uuid":"11588390","full_name":"ryan-endacott/verbal_expressions","owner":"ryan-endacott","description":"Make difficult regular expressions easy! Ruby port of the awesome VerbalExpressions repo - https://github.com/jehna/VerbalExpressions","archived":false,"fork":false,"pushed_at":"2023-01-09T22:10:23.000Z","size":45,"stargazers_count":571,"open_issues_count":11,"forks_count":25,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-22T18:25:53.095Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryan-endacott.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-22T18:07:40.000Z","updated_at":"2025-03-19T17:53:39.000Z","dependencies_parsed_at":"2023-01-13T10:17:35.512Z","dependency_job_id":null,"html_url":"https://github.com/ryan-endacott/verbal_expressions","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryan-endacott%2Fverbal_expressions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryan-endacott%2Fverbal_expressions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryan-endacott%2Fverbal_expressions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryan-endacott%2Fverbal_expressions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryan-endacott","download_url":"https://codeload.github.com/ryan-endacott/verbal_expressions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253217324,"owners_count":21873067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T06:01:32.548Z","updated_at":"2025-05-09T08:33:22.783Z","avatar_url":"https://github.com/ryan-endacott.png","language":"Ruby","funding_links":[],"categories":["Ruby","Language Aware String Manipulation"],"sub_categories":["Text-to-Speech-to-Text"],"readme":"verbal_expressions\n=====================\n[![Build Status](https://travis-ci.org/ryan-endacott/verbal_expressions.png)](https://travis-ci.org/ryan-endacott/verbal_expressions)\n[![Gem Version](https://badge.fury.io/rb/verbal_expressions.png)](http://badge.fury.io/rb/verbal_expressions)\n## Ruby Regular Expressions made easy\nVerbalExpressions is a Ruby library that helps to construct difficult regular expressions - ported from the awesome JavaScript [VerbalExpressions](https://github.com/jehna/VerbalExpressions).\n\n## How to get started\n\nJust install with `gem install verbal_expressions`, then require the library and you're good to go!\n```ruby\nrequire 'verbal_expressions'\n```\n\n## Examples\n\nHere's a couple of simple examples to give an idea of how VerbalExpressions works:\n\n### Testing if we have a valid URL\n\n```ruby\n# Create an example of how to test for correctly formed URLs\ntester = VerEx.new do\n  start_of_line\n  find 'http'\n  maybe 's'\n  find '://'\n  maybe 'www.'\n  anything_but ' '\n  end_of_line\nend\n\n# Create an example URL\ntest_url = \"https://www.google.com\"\n\n# Use it just like a regular Ruby regex:\nputs 'Hooray!  It works!' if tester.match(test_url)\nputs 'This works too!' if tester =~ test_url\n\n# Print the generated regex:\nputs tester.source # =\u003e /^(http)(s)?(\\:\\/\\/)(www\\.)?([^\\ ]*)$/\n```\n\n### Replacing strings\n\n```ruby\n# Create a test string\nreplace_me = \"Replace bird with a duck\"\n\n# Create an expression that seeks for word \"bird\"\nexpression = VerEx.new { find 'bird' }\n\n# Execute the expression like a normal Regexp object\nresult = replace_me.gsub( expression, \"duck\" );\n\nputs result # Outputs \"Replace duck with a duck\"\n```\n\n### Regex Capturing\n\n```ruby\n# Grab the number of goals\n\ntester = VerEx.new do\n  find 'scored '\n  begin_capture 'goals' # Can be named or unnamed\n  word\n  end_capture\nend\n\nmatch = tester.match('Jerry scored 5 goals!')\nputs match['goals'] # =\u003e 5\n\n# Alternative capture syntax\n\ntester = VerEx.new do\n  find 'scored '\n  capture('goals') { word }\nend\n```\n\n## API documentation\n\nI haven't added much documentation to this repo yet, but you can find the documentation for the original JavaScript repo on their [wiki](https://github.com/jehna/VerbalExpressions/wiki).  Most of the methods have been ported as of v0.1.0 of the JavaScript repo.  Just be sure to use the syntax explained above rather than the dot notation :)\n\n## Contributions\nClone the repo and fork!\nPull requests are warmly welcomed!\n\n## Issues\n - I haven't yet ported the modifier code because Ruby Regexp handles modifiers a little differently.\n - Because `or` is reserved in Ruby, `or` is currently aliased to `alternatively`.  Unfortunately, `then` is also reserved, so you must use `find` instead.  I'm very open to better name ideas :)\n\n## Thanks!\nThank you to @jehna for coming up with the awesome original idea!\n\n\n\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/ryan-endacott/verbal_expressions/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryan-endacott%2Fverbal_expressions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryan-endacott%2Fverbal_expressions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryan-endacott%2Fverbal_expressions/lists"}