{"id":2513,"library":"flpc","title":"Lightning-Fast Python Regex (flpc)","description":"flpc is a powerful Python library that wraps the blazing-fast Rust regex crate, bringing enhanced speed to your regular expression operations. It is designed to be a drop-in replacement for Python's native `re` module, with some minor syntax differences. Currently at version 0.2.5, it is in an experimental stage, meaning its code structure and dependencies may change, and users should be prepared for manual migrations to newer versions.","status":"active","version":"0.2.5","language":"en","source_language":"en","source_url":"https://github.com/itsmeadarsh2008/flpc.git","tags":["regex","performance","rust","re","regular expressions"],"install":[{"cmd":"pip install flpc","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"While designed as a replacement for Python's `re` module, you must import `flpc` directly.","wrong":"import re","symbol":"flpc","correct":"import flpc"},{"note":"The `match` function is renamed to `fmatch` to avoid conflicts with Python's keyword `match`.","wrong":"flpc.match(pattern, string)","symbol":"fmatch","correct":"flpc.fmatch(pattern, string)"}],"quickstart":{"code":"import flpc\n\n# Using flpc.search\ntext = \"Hello world, hello Rust!\"\npattern = r\"hello (\\w+)\"\n\nmatch_obj_search = flpc.search(pattern, text, flpc.IGNORECASE)\nif match_obj_search:\n    print(f\"Search found: {match_obj_search.group(0)}\") # group(0) for entire match\n    print(f\"Captured group: {match_obj_search.group(1)}\")\nelse:\n    print(\"No match found by search.\")\n\n# Using flpc.fmatch (equivalent to re.match, matches only at the beginning)\ntext_start = \"Hello Python, hello flpc!\"\npattern_start = r\"Hello (\\w+)\"\n\nmatch_obj_fmatch = flpc.fmatch(pattern_start, text_start)\nif match_obj_fmatch:\n    print(f\"fmatch found: {match_obj_fmatch.group(0)}\")\n    print(f\"Captured group: {match_obj_fmatch.group(1)}\")\nelse:\n    print(\"No match found by fmatch.\")\n\n# Compile a pattern for efficiency\ncompiled_pattern = flpc.compile(r\"rust\", flpc.IGNORECASE)\nmatch_compiled = compiled_pattern.search(text)\nif match_compiled:\n    print(f\"Compiled pattern search found: {match_compiled.group(0)}\")","lang":"python","description":"This quickstart demonstrates basic usage of `flpc.search` for finding patterns anywhere in a string, `flpc.fmatch` for matching patterns only at the beginning of a string, and how to compile patterns for repeated use. It also highlights the use of `group(index)` for accessing captured groups."},"warnings":[{"fix":"Always use `flpc.fmatch()` instead of `flpc.match()`.","message":"The `match()` function from the standard `re` module is renamed to `fmatch()` in `flpc` to avoid conflict with Python's `match` keyword. Direct calls to `flpc.match()` will fail.","severity":"breaking","affected_versions":"All versions"},{"fix":"Ensure an integer index is always passed to the `group()` method (e.g., `match_obj.group(0)`).","message":"When accessing captured groups from a match object using `group()`, an index must always be provided (e.g., `group(0)` for the entire match, `group(1)` for the first captured group). Calling `group()` without an argument is not supported.","severity":"breaking","affected_versions":"All versions"},{"fix":"Regularly consult the official GitHub repository and PyPI page for updates and potential migration instructions if you choose to use `flpc` in production environments.","message":"The `flpc` library is currently in an experimental stage. Its code structure and internal dependencies are subject to change, which may necessitate manual migrations for your project with future updates.","severity":"gotcha","affected_versions":"All versions (as of 0.2.5)"},{"fix":"Wrap access to match object methods within an `if match_obj:` block.","message":"Always check if a match object is returned (i.e., not `None`) before attempting to access its methods like `group()`, `start()`, or `end()`. Accessing methods on a `None` object will result in an `AttributeError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Thoroughly test `flpc` with your specific regex patterns and use cases to ensure compatibility and expected behavior. Refer to the GitHub API section for known differences.","message":"While `flpc` aims to mirror the `re` module's API, it is not a complete, drop-in replacement. Minor behavioral differences or unimplemented functionalities compared to the standard `re` module might exist.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}