{"id":17182338,"url":"https://github.com/davidhu2000/regex_crash_course","last_synced_at":"2026-01-05T16:40:46.289Z","repository":{"id":66101798,"uuid":"88887626","full_name":"davidhu2000/regex_crash_course","owner":"davidhu2000","description":"A crash course on how to use Regular Expressions","archived":false,"fork":false,"pushed_at":"2017-04-21T04:38:04.000Z","size":1,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T01:44:28.506Z","etag":null,"topics":["pattern-matching","regex","regex-pattern","regexp"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidhu2000.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-20T16:31:36.000Z","updated_at":"2025-01-06T10:41:12.000Z","dependencies_parsed_at":"2023-03-03T14:30:31.108Z","dependency_job_id":null,"html_url":"https://github.com/davidhu2000/regex_crash_course","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/davidhu2000/regex_crash_course","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhu2000%2Fregex_crash_course","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhu2000%2Fregex_crash_course/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhu2000%2Fregex_crash_course/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhu2000%2Fregex_crash_course/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidhu2000","download_url":"https://codeload.github.com/davidhu2000/regex_crash_course/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhu2000%2Fregex_crash_course/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28217663,"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":"2026-01-05T02:00:06.358Z","response_time":57,"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":["pattern-matching","regex","regex-pattern","regexp"],"created_at":"2024-10-15T00:36:45.795Z","updated_at":"2026-01-05T16:40:46.259Z","avatar_url":"https://github.com/davidhu2000.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# A crash course on how to use regular expressions\n\n**NB:** this crash course uses Ruby as the default language.\n\nRegular expressions are used to match patterns in strings. This repo serves as a crash course on how to use regular expression.\n\n## Creating a regex object\n\nThere are three ways to create a `regex` object.\n\n    /.../\n    %r{...}\n    Regexp.new(...)\n\nwhere `...` is the desired pattern.\n\n## Methods\n\n    'hello' =~ /world/ #=\u003e nil\n    'banana' =~ /ana/  #=\u003e 1\n\n`=~` is Ruby's basic pattern matching operator, where one side is a string, and the other side is regular expression. This method returns the index of the first match in the string.\n\n    /adam/.match('madam')   #=\u003e \u003cMatchData 'adam'\u003e\n    /yolo/.match('careful') #=\u003e nil\n\n`#match` returns a MatchData object.\n\nThere are other methods that can use regular expression to pattern match. For example, `String#split` and `Array#scan`.\n\n## Characters Classes\n\n| character | function                                 |\n|:---------:|------------------------------------------|\n|    `.`    | any single character except new line     |\n|  `[abc]`  | any character in the set                 |\n| `[^abc]`  | any character not in the set             |\n|  `[a-z]`  | any character from `a` to `z`.           |\n|   `\\w`    | any word character `[a-zA-Z0-9_]`        |\n|   `\\W`    | any non-word character   `[^a-zA-Z0-9_]` |\n|   `\\d`    | any digit character `[0-9]`              |\n|   `\\D`    | any non-word character   `[^0-9]`        |\n|   `\\s`    | a whitespace character                   |\n|   `\\S`    | any non-word character                   |\n|   `\\h`    | a hexdigit character `[0-9a-fA-F]`       |\n|   `\\H`    | a non-hexdigit character `[^0-9a-fA-F]`  |\n\n### Escaped Special Characters\n\nThese characters have special meanings in regular expressions and needs to be escaped if you want to match that exact character.\n\n`\\.`, `\\\\`, `\\*`, `\\+`, `\\?`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidhu2000%2Fregex_crash_course","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidhu2000%2Fregex_crash_course","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidhu2000%2Fregex_crash_course/lists"}