{"id":22980932,"url":"https://github.com/rubyworks/regex","last_synced_at":"2025-08-13T17:33:29.772Z","repository":{"id":56891655,"uuid":"506911","full_name":"rubyworks/regex","owner":"rubyworks","description":"Regular Expressions on the Clamshell","archived":false,"fork":false,"pushed_at":"2013-02-15T20:53:54.000Z","size":496,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-09T21:03:31.903Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://rubyworks.github.com/regex","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubyworks.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-02-07T21:14:38.000Z","updated_at":"2019-06-01T20:54:53.000Z","dependencies_parsed_at":"2022-08-20T16:01:04.567Z","dependency_job_id":null,"html_url":"https://github.com/rubyworks/regex","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rubyworks/regex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fregex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fregex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fregex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fregex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubyworks","download_url":"https://codeload.github.com/rubyworks/regex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fregex/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269827209,"owners_count":24481488,"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","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-12-15T01:46:13.240Z","updated_at":"2025-08-13T17:33:29.531Z","avatar_url":"https://github.com/rubyworks.png","language":"Ruby","readme":"# Regex (\"Like a Knife\")\n\n[Website](http://rubyworks.github.com/regex) /\n[Report Issue](http://github.com/rubyworks/regex/issues) /\n[Source Code](http://github.com/rubyworks/regex) /\n[Chat Room](irc://irc.freenode.net/rubyworks) /\n[![Build Status](https://secure.travis-ci.org/rubyworks/regex.png)](http://travis-ci.org/rubyworks/regex) /\n[![Gem Version](https://badge.fury.io/rb/regex.png)](http://badge.fury.io/rb/regex)\n\n\n## About\n\nYea, I know what you are going to say, \"You just reimplmented `sed`!\" And\nyou would be absolutely correct. But! There is a little bit more to this story.\nSed is not a \"Langauge 2.0\" tool (i.e. \"post-Ruby\"). And want I wanted is a\ncommand-line tool that is both a bit easier to use and a bit more flexible\nas well.\n\nNow I could have written this in Perl. I'm sure it would just as good, if not\nbetter since Perl's Regular Expression engine rocks, or so I hear. But Ruby's is\npretty damn good too, and getting better (with 1.9+). And since I know Ruby very\nwell. Well that's what you get.\n\n\n## Usage\n\nFor detailed explication and examples of usage refer to the\n[User Docs](http://wiki.github.com/rubyworks/regex), the\n[QED Docs](http://github.com/rubyworks/regex/docs/qed) and the\n[API Docs](http://github.com/rubyworks/regex/docs/api).\n\nIn brief, usage simply entails supplying a regular expression and a list of files\nto be searched to the `regex` command.\n\n    $ regex '/=begin.*?\\n(.*)\\n=end/' sample.rb\n\nThis example does exactly what you would expect. It returns the content between\nthe first `=begin ... =end` clause it comes across. To see all such\nblock comments, as you would expect, you can use add the `g` regular\nexpression mode flag.\n\n    $ regex '/=begin.*?\\n(.*)\\n=end/g' sample.rb\n\nAlternatively you can use the `-g/--global/--repeat` option.\n\n    $ regex -g '/=begin.*?\\n(.*)\\n=end/' sample.rb\n\nNotice that in all these examples we have used single quotes to wrap the\nregular expression. This is to prevent the shell from expanding `*`\nand `?` marks.\n\nBy default regex produces string output. Regular expression groups are delimited\nby ASCII 29 (035 1D) END OF GROUP, and repeat matches are delimited by\nASCII character 30 (036 1E) END OF RECORD.\n\nInstead of string output, regex also supports YAML and JSON formats using the\n`--yaml/-y` and `--json/-j` flags.\n\n    $ regex -y -g '/=begin.*?\\n(.*)\\n=end/' sample.rb\n\nIn this case the returned matches are delimited using as an array of arrays.\n\nTo get more information than just the match results use the `--detail/-d`\noption.\n\nAlso, we can do without the `/ /` deliminators on the regular\nexpression if we use the `--search/-s` option instead. Going back to\nour first example:\n\n    $ regex -s '=begin.*?\\n(.*)\\n=end' sample.rb\n\nTo replace text, use the `--replace/--r` option.\n\n    $ regex --yaml --repeat -s 'Tom' -r 'Bob' sample.rb\n\nThis will replace every occurrence of \"Tom\" with \"Bob\" in the `sample.rb`\nfile. By default `regex` will backup any file it changes by adding a\n`.bak` extension to the original copy.\n\nCheck out the `--help` and I am sure the rest will be smooth sailing.\nBut it you want more information, then do us the good favor of jumping over\nto the [wiki](http://wiki.github.com/rubyworks/regex). Feel free to add\nadditional information there to help others.\n\n\n## Output\n\nAs mentioned above, regex has three output modes. YAML, JSON and standard text.\nThe standard text output is unique in that it utilizes special ASCII characters\nto separate matches and regex groups. ASCII 29, called the *record separator*,\nis used to separate repeat matches. ASCII 30, called the *group separator*, is\nis used to separate regular expression groups.\n\n\n## Status\n\nThe project is maturing but still a touch wet behind the ears. So don't be too\nsurprised if it doesn't have every feature under the sun just yet, or that every\ndetail is going to work absolutely peachy. But hey, if something needs fixing or\na feature needs adding, well then get in there and send us a patch. Open source\nsoftware is built on *TEAM WORK*, right?\n\n\n## Copyrights\n\nCopyright \u0026copy; 2010 Rubyworks\n\nRegex is licensed under the terms of the *FreeBSD* license.\n\nSee LICENSE.txt file for details.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyworks%2Fregex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyworks%2Fregex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyworks%2Fregex/lists"}