# 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/titans2024/baby.git",
"name": "BabyStep",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "baby sorting and search",
"author": "Muthukumaran",
"author_email": "titansmuthu@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/38/53/43ec2acc1b29b3d8dae222719651718ac0564212212e751143c15dfb1614/babystep-0.0.1.tar.gz",
"platform": null,
"description": "# baby\r\n\r\nPython Regular Expressions (Regex) Search Methods\r\nThis 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.\r\n\r\nTable of Contents\r\nRequirements\r\nFunctions\r\nbasic_search\r\nfind_all_occurrences\r\nmatch_search\r\nfind_all_matches\r\nsplit_by_pattern\r\nfull_match_search\r\nextract_groups\r\nsearch_with_position\r\nsubstitute_pattern\r\ncase_insensitive_search\r\noptional_pattern_search\r\nUsage\r\nRequirements\r\nPython 3.x or higher\r\nre module (comes built-in with Python)\r\nFunctions\r\n1. basic_search(text, pattern)\r\nSearch for the first occurrence of a pattern in the given text.\r\n\r\nArgs:\r\n\r\ntext (str): The string in which to search for the pattern.\r\npattern (str): The pattern to search for.\r\nReturns:\r\n\r\nstr: The matched pattern, or \"No match found\" if no match is found.\r\n2. find_all_occurrences(text, pattern)\r\nFind all occurrences of a pattern in the given text.\r\n\r\nArgs:\r\n\r\ntext (str): The string in which to find the occurrences of the pattern.\r\npattern (str): The pattern to search for.\r\nReturns:\r\n\r\nlist: A list of all matches found.\r\n3. match_search(text, pattern)\r\nCheck if the pattern matches at the start of the string.\r\n\r\nArgs:\r\n\r\ntext (str): The string to check for the pattern.\r\npattern (str): The pattern to match at the start of the string.\r\nReturns:\r\n\r\nstr: The matched string, or \"No match at the start\" if the pattern doesn't match at the start.\r\n4. find_all_matches(text, pattern)\r\nFind all non-overlapping matches of a pattern in the given text.\r\n\r\nArgs:\r\n\r\ntext (str): The string to search for all matches.\r\npattern (str): The pattern to search for.\r\nReturns:\r\n\r\nlist: A list of all match groups found.\r\n5. split_by_pattern(text, pattern)\r\nSplit the text by occurrences of the pattern.\r\n\r\nArgs:\r\n\r\ntext (str): The string to split.\r\npattern (str): The pattern by which to split the string.\r\nReturns:\r\n\r\nlist: A list of strings resulting from the split.\r\n6. full_match_search(text, pattern)\r\nCheck if the entire string matches the pattern.\r\n\r\nArgs:\r\n\r\ntext (str): The string to check for a full match.\r\npattern (str): The pattern to match against the entire string.\r\nReturns:\r\n\r\nstr: The matched string, or \"No full match\" if the entire string does not match the pattern.\r\n7. extract_groups(text, pattern)\r\nExtract captured groups from the text using the given pattern.\r\n\r\nArgs:\r\n\r\ntext (str): The string to extract groups from.\r\npattern (str): The pattern with capture groups to extract.\r\nReturns:\r\n\r\ntuple: A tuple of captured groups, or \"No match\" if no match is found.\r\n8. search_with_position(text, pattern)\r\nSearch for a pattern and return its position in the string.\r\n\r\nArgs:\r\n\r\ntext (str): The string to search for the pattern.\r\npattern (str): The pattern to search for.\r\nReturns:\r\n\r\ntuple: A tuple containing the start and end position of the match, or \"No match\" if no match is found.\r\n9. substitute_pattern(text, pattern, replacement)\r\nSubstitute the occurrences of a pattern with a replacement string.\r\n\r\nArgs:\r\n\r\ntext (str): The string in which to substitute the pattern.\r\npattern (str): The pattern to find.\r\nreplacement (str): The string to replace the pattern with.\r\nReturns:\r\n\r\nstr: The modified string with the pattern replaced by the replacement.\r\n10. case_insensitive_search(text, pattern)\r\nPerform a case-insensitive search for a pattern in the text.\r\n\r\nArgs:\r\n\r\ntext (str): The string in which to search for the pattern.\r\npattern (str): The pattern to search for.\r\nReturns:\r\n\r\nstr: The matched pattern, or \"No match found\" if no match is found.\r\n11. optional_pattern_search(text, pattern)\r\nSearch for an optional pattern in the string.\r\n\r\nArgs:\r\n\r\ntext (str): The string to search for the pattern.\r\npattern (str): The pattern with optional parts to search for.\r\nReturns:\r\n\r\nstr: The matched pattern, or \"No match found\" if no match is found.\r\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "All Basic sorting and search",
"version": "0.0.1",
"project_urls": {
"Download": "https://github.com/titans2024/baby/archive/refs/heads/main.zip",
"Homepage": "https://github.com/titans2024/baby.git"
},
"split_keywords": [
"baby",
"sorting",
"and",
"search"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "17136cfa19b44846e7fdb7001691a79e2a2275cbcd7b9cb45a0bc14ac20c89fe",
"md5": "811e4c4bbba0b5167bfc28528e9dd589",
"sha256": "7f37256491d37b1aea648c2ab4855f21884d2f05a24e9e39aec60d8323d236cd"
},
"downloads": -1,
"filename": "BabyStep-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "811e4c4bbba0b5167bfc28528e9dd589",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 6153,
"upload_time": "2025-02-03T05:24:56",
"upload_time_iso_8601": "2025-02-03T05:24:56.169036Z",
"url": "https://files.pythonhosted.org/packages/17/13/6cfa19b44846e7fdb7001691a79e2a2275cbcd7b9cb45a0bc14ac20c89fe/BabyStep-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "385343ec2acc1b29b3d8dae222719651718ac0564212212e751143c15dfb1614",
"md5": "0b7f6272728fb6afa043f498be1c9e2e",
"sha256": "464f706f6b5baf1d9eaf67dc75888225ec3dc0c01932c44f5586d6612b57be3b"
},
"downloads": -1,
"filename": "babystep-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "0b7f6272728fb6afa043f498be1c9e2e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 5824,
"upload_time": "2025-02-03T05:24:58",
"upload_time_iso_8601": "2025-02-03T05:24:58.185225Z",
"url": "https://files.pythonhosted.org/packages/38/53/43ec2acc1b29b3d8dae222719651718ac0564212212e751143c15dfb1614/babystep-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-03 05:24:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "titans2024",
"github_project": "baby",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "babystep"
}