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.3.tar.gz (5.8 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.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: babystep-0.0.3.tar.gz
  • Upload date:
  • Size: 5.8 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.3.tar.gz
Algorithm Hash digest
SHA256 943c6831f42bb5c1577a163b0789c457af611bf5552074ac0a6aa37a1846e4b5
MD5 322ae5db7217e086f4ecb0de16b5374f
BLAKE2b-256 1999e947f63d660678cb725591525dd56e28769dcd4e7d084de37c325eac358a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: BabyStep-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.0 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c4b397b5e79567dd4eb5c562ce017806716e6d8ed93cf82cb652e74b13473e91
MD5 52531d81407cc2420fa7dc74aef8f38c
BLAKE2b-256 dab9b3643900ee8c8b38277f6b3e6aae027a94decdbbb911562bb1070d2b211a

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