Skip to main content

All Basic sorting and search

Project description

baby

Python Regular Expressions (Regex) Search Methods This repository provides a collection of Python functions for performing various types of regular expression (regex) searches. The functions allow you to search, find, extract, substitute, and manipulate strings using regular expressions in a flexible way. Each function is self-contained and provides a specific regex operation to handle different search and pattern matching tasks.

Table of Contents Requirements Functions basic_search find_all_occurrences match_search find_all_matches split_by_pattern full_match_search extract_groups search_with_position substitute_pattern case_insensitive_search optional_pattern_search Usage Requirements Python 3.x or higher re module (comes built-in with Python) Functions

  1. basic_search(text, pattern) Search for the first occurrence of a pattern in the given text.

Args:

text (str): The string in which to search for the pattern. pattern (str): The pattern to search for. Returns:

str: The matched pattern, or "No match found" if no match is found. 2. find_all_occurrences(text, pattern) Find all occurrences of a pattern in the given text.

Args:

text (str): The string in which to find the occurrences of the pattern. pattern (str): The pattern to search for. Returns:

list: A list of all matches found. 3. match_search(text, pattern) Check if the pattern matches at the start of the string.

Args:

text (str): The string to check for the pattern. pattern (str): The pattern to match at the start of the string. Returns:

str: The matched string, or "No match at the start" if the pattern doesn't match at the start. 4. find_all_matches(text, pattern) Find all non-overlapping matches of a pattern in the given text.

Args:

text (str): The string to search for all matches. pattern (str): The pattern to search for. Returns:

list: A list of all match groups found. 5. split_by_pattern(text, pattern) Split the text by occurrences of the pattern.

Args:

text (str): The string to split. pattern (str): The pattern by which to split the string. Returns:

list: A list of strings resulting from the split. 6. full_match_search(text, pattern) Check if the entire string matches the pattern.

Args:

text (str): The string to check for a full match. pattern (str): The pattern to match against the entire string. Returns:

str: The matched string, or "No full match" if the entire string does not match the pattern. 7. extract_groups(text, pattern) Extract captured groups from the text using the given pattern.

Args:

text (str): The string to extract groups from. pattern (str): The pattern with capture groups to extract. Returns:

tuple: A tuple of captured groups, or "No match" if no match is found. 8. search_with_position(text, pattern) Search for a pattern and return its position in the string.

Args:

text (str): The string to search for the pattern. pattern (str): The pattern to search for. Returns:

tuple: A tuple containing the start and end position of the match, or "No match" if no match is found. 9. substitute_pattern(text, pattern, replacement) Substitute the occurrences of a pattern with a replacement string.

Args:

text (str): The string in which to substitute the pattern. pattern (str): The pattern to find. replacement (str): The string to replace the pattern with. Returns:

str: The modified string with the pattern replaced by the replacement. 10. case_insensitive_search(text, pattern) Perform a case-insensitive search for a pattern in the text.

Args:

text (str): The string in which to search for the pattern. pattern (str): The pattern to search for. Returns:

str: The matched pattern, or "No match found" if no match is found. 11. optional_pattern_search(text, pattern) Search for an optional pattern in the string.

Args:

text (str): The string to search for the pattern. pattern (str): The pattern with optional parts to search for. Returns:

str: The matched pattern, or "No match found" if no match is found.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

babystep-0.0.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

BabyStep-0.0.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file babystep-0.0.2.tar.gz.

File metadata

  • Download URL: babystep-0.0.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.0

File hashes

Hashes for babystep-0.0.2.tar.gz
Algorithm Hash digest
SHA256 31553ce085e43cd6326cb8e1e65d47d1f2d29470d180d1386af26f22a459dc26
MD5 4ea84a4ec4defd35494238d505ab574f
BLAKE2b-256 6286639f75d2ae1f77d40a786f007b1d774207256af16afc818c1052f7524349

See more details on using hashes here.

File details

Details for the file BabyStep-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: BabyStep-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.0

File hashes

Hashes for BabyStep-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3235cea13ed8a69aea00130e308f48f4d3e02374db1bd1f1623bd763e5564ff1
MD5 c5835b02b8bfefedf5c7b9b271875f0e
BLAKE2b-256 80f362499088e21668f4d598498c66e20c8d6d6ffcb492df1d2e05a02041859c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page