{"id":31729838,"url":"https://github.com/ron4fun/srl-cpp","last_synced_at":"2025-10-09T07:18:08.629Z","repository":{"id":144178307,"uuid":"203958579","full_name":"ron4fun/SRL-CPP","owner":"ron4fun","description":"SRL-CPP is a Simple Regex Language builder library written in C++11 that provides an easy to use interface for constructing both simple and complex regex expressions.","archived":false,"fork":false,"pushed_at":"2021-10-18T19:08:13.000Z","size":2054,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-07-23T05:38:54.403Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","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/ron4fun.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-08-23T08:36:27.000Z","updated_at":"2022-03-09T19:18:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"dca39866-3eff-4087-852d-35d0986c6ca0","html_url":"https://github.com/ron4fun/SRL-CPP","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ron4fun/SRL-CPP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ron4fun%2FSRL-CPP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ron4fun%2FSRL-CPP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ron4fun%2FSRL-CPP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ron4fun%2FSRL-CPP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ron4fun","download_url":"https://codeload.github.com/ron4fun/SRL-CPP/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ron4fun%2FSRL-CPP/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000985,"owners_count":26082972,"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-10-09T02:00:07.460Z","response_time":59,"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":"2025-10-09T07:18:06.919Z","updated_at":"2025-10-09T07:18:08.623Z","avatar_url":"https://github.com/ron4fun.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SRL-CPP [![License](http://img.shields.io/badge/license-MIT-green.svg)](https://github.com/ron4fun/SRL-CPP/blob/master/LICENSE)\nSRL-CPP is a Simple Regex Language builder library written in C++11 that provides an easy to use interface for constructing both simple and complex regex expressions.\n\nIt also supports **capture names**.\n\n**CHARACTERS Methods:**\n\n    raw(string)\t // Add raw Regular Expression to current expression.\n\toneOf(string)  // Literally match one of these characters.\n\tnoneOf(string)  // Literally match a character that is not one of these characters.\n\tliterally(string)  // Literally match all of these characters in that order.\n\tdigit(int,int)  // Match any digit (in given span). Default will be a digit between 0 and 9.\n\tnumber(int,int) // Match any number (in given span). Default will be a number between 0 and 9.\n\tnoDigit()  // Match any non-digit character (in given span). Default will be any character not between 0 and 9.\n\tuppercaseLetter(char,char)  // Match any uppercase letter (between A to Z).\n\tletter(char,char)  // Match any lowercase letter (between a to z).\n\t\n**GROUPS Methods:**\n\n\tanyOf(Closure|Builder|string)  // Match any of these conditions.\n\teitherOf(Closure|Builder|string)  // Match any of these conditions.\n\tgroup(Closure|Builder|string)  // Match all of these conditions, but in a non capture group.\n\tand(Closure|Builder|string)  // Match all of these conditions, Basically reverts back to the default mode, if coming from anyOf, etc.\n\tifFollowedBy(Closure|Builder|string)  // Positive lookahead. Match the previous condition only if followed by given conditions.\n\tifNotFollowedBy(Closure|Builder|string)  // Negative lookahead. Match the previous condition only if NOT followed by given conditions.\n\tcapture(Closure|Builder|string, null|string)  // Create capture group of given conditions.\n\t\n**QUANTIFIERS Methods:**\n\n\toptional(null|Closure|Builder|string)  // Make the last or given condition optional.\n\tbetween(int,int)  // Previous match must occur so often.\n\tatLeast(int)  // Previous match must occur at least this often.\n\tonce()  // Previous match must occur exactly once.\n\ttwice()  // Previous match must occur exactly twice.\n\texactly(int)  // Previous match must occur exactly this often.\n\tlazy()  // Match less chars instead of more (lazy).\n\tuntil(Closure|Builder|string)  // Match up to the given condition.\n\n**MODIFIER MAPPER Methods:**\n\t\n\taddUniqueModifier(int)  // Add a specific unique modifier. This will ignore all modifiers already set.\n\tECMAScript()  // Add ECMA script modifier.\n\tcaseInsensitive()  // Add case-insensitive modifier.\n \n**SIMPLE MAPPER Methods:**\n\n\tstartsWith()\n\tbeginWith()\n\tmustEnd()\n\tonceOrMore()\n\tneverOrMore()\n\tany()\n\tbackslash()\n\ttab()\n\tverticalTab()\n\tnewLine()\n\twhitespace()\n\tnoWhitespace()\n\tanyCharacter()\n\tnoCharacter()\n\tword()\n\tnonWord()\n\n**INTERNAL Methods:**\n\n\tescape(char)  // Escape specific character.\n\tgetRawRegex()  // Get the raw regular expression string.\n\tgetModifiers()  // Get the union of all set modifiers.\n\tremoveModifier(int)  // Remove specific flag.\n\tadd(string)  // Add condition to the expression query.\n\tget()  // Build and return the resulting RegExp object. This will apply all the modifiers.\n\tisValid()  // Validate regular expression.\n\tclone()  // Clone a new builder object.\n\tisMatchContained(string)  // Check if the target string contains any substring that matches the regex pattern.\n\tisExactMatch(string)  // Check if the target string matches the pattern completely.\n\tisMatching(string)  // Check if the target string matches the pattern completely or partly.\n\treplace(string,string)  // Search and replace patterns within a string of text.\n\tgetMatch(string)  // Get the first substring contained in the target string that matches the regex pattern.\n\tgetMatches(string) // Get all matches.\n    \n**Usage Examples.**\n\nThe SRL function accepts a Simple Regex Language string as input, and return the builder for the query. \n\n```c++\n#include \"SRL.h\"\n\nint main()\n{\n    Builder query = SRL().literally(\"colo\").optional((string)\"u\").literally(\"r\").anyOf(\n\t[](Builder\u0026 builder) {\n\tbuilder.literally(\":\").and(\n\t[](Builder\u0026 builder) {\n\t    builder.literally(\" is\");\n\t});\n    }).whitespace().capture(\n\t[](Builder\u0026 builder) {\n\t    builder.letter().onceOrMore();\n    }).literally(\".\");\n\t\t\n    auto matches = query.getMatches(\"my favorite colour is green. And my favorite color: yellow.\");\n\t\n    bool match_1 = matches[0][\"0\"];\n    bool match_2 = matches[1][\"0\"];  \n  \n    query = SRL(\"literally \\\"color:\\\", whitespace, capture (letter once or more), literally \\\".\\\", all\");\n\n    matches = query.getMatches(\"my favorite colour is green. And my favorite color: yellow.\");\n\t\n    bool match_3 = matches[0][\"0\"];\n    bool match_4 = matches[1][\"0\"];\n\n    cout \u003c\u003c match_1 == match_3 \u003c\u003c \": \" \u003c\u003c match_1 \u003c\u003c endl; \n    cout \u003c\u003c match_2 == match_4 \u003c\u003c \": \" \u003c\u003c match_2 \u003c\u003c endl; \n\n    query = SRL(\"begin with capture (letter twice) as \\\"basename\\\", must end\");\n    matches = query.getMatches(\"aa\");\n\n    cout \u003c\u003c matches[0][\"basename\"] \u003c\u003c endl;\n\n    // Quite a complex regex expression\n    query = SRL(\"begin with literally \\\"http\\\", optional \\\"s\\\", literally \\\"://\\\", optional \\\"www.\\\", anything once or more, literally \\\".com\\\", must end\");\n\t\n    cout \u003c\u003c query.isMatching(\"http://www.google.com\") \u003c\u003c endl;\n    cout \u003c\u003c query.isMatching(\"https://google.com\") \u003c\u003c endl;\n    cout \u003c\u003c query.isMatching(\"htt://google.com\") \u003c\u003c endl;\n\n    return 0;\n}\n```\n\n**Tested Enviroments:**\n     \n    Visual Studio 2015.\n    Visual Studio 2017.\n\n **Unit Tests:**\n\n\tTo run the unit tests, you should have [boost library](http://www.boost.org/) \n\tinstalled in your workstation.\n\t\n\tFor Visual Studio, set environment variable BOOST_ROOT to your boost root folder \n\t(where the binary is).\n\tAlso on 64 bit you might need to compile with additional command /bigobj.\n\nYou can also check out how to write Rules, see: [Test-Rules](https://github.com/SimpleRegex/Test-Rules).\n\n###License\n\nThis \"Software\" is Licensed Under  **`MIT License (MIT)`** .\n\n#### Tip Jar\n* :dollar: **Bitcoin**: `1Mcci95WffSJnV6PsYG7KD1af1gDfUvLe6`\n\n\nConclusion\n--------------------------------------------------\n\n   Special thanks to [Simple Regex](https://simple-regex.com/) for making this library available to port from in the first place.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fron4fun%2Fsrl-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fron4fun%2Fsrl-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fron4fun%2Fsrl-cpp/lists"}