Fast string search, matching, and analysis powered by BMB — KMP, find, replace, case conversion
Project description
bmb-text — Fast String Processing
KMP search, substring operations, case conversion, and text analysis compiled from BMB.
Installation
pip install bmb-text
Quick Start
import bmb_text
bmb_text.kmp_search("hello world", "world") # 6
bmb_text.str_replace_all("abcabc", "abc", "X") # "XX"
bmb_text.to_upper("hello") # "HELLO"
bmb_text.trim(" hello ") # "hello"
bmb_text.is_palindrome("racecar") # True
bmb_text.word_count("hello world") # 2
bmb_text.repeat("ab", 3) # "ababab"
bmb_text.hamming_distance("karolin", "kathrin") # 3
Full API (23 functions)
Search
| Function | Description |
|---|---|
kmp_search(text, pattern) |
KMP substring search O(n+m), returns index or -1 |
str_find(haystack, needle) |
Find first occurrence |
str_rfind(haystack, needle) |
Find last occurrence |
str_count(haystack, needle) |
Count non-overlapping occurrences |
str_contains(haystack, needle) |
Contains check |
str_starts_with(s, prefix) |
Prefix check |
str_ends_with(s, suffix) |
Suffix check |
find_byte(s, byte) |
Find byte value in string |
count_byte(s, byte) |
Count byte occurrences |
Transform
| Function | Description |
|---|---|
str_reverse(s) |
Reverse string |
str_replace(s, old, new) |
Replace first occurrence |
str_replace_all(s, old, new) |
Replace all occurrences |
to_upper(s) |
Convert to UPPERCASE |
to_lower(s) |
Convert to lowercase |
trim(s) |
Trim leading/trailing whitespace |
repeat(s, n) |
Repeat string n times |
Analysis
| Function | Description |
|---|---|
is_palindrome(s) |
Palindrome check |
hamming_distance(a, b) |
Hamming distance between equal-length strings |
word_count(s) |
Count whitespace-separated words |
token_count(s, delimiter) |
Count delimiter-separated tokens |
str_len(s) |
String length in bytes |
str_char_at(s, idx) |
Byte value at index (-1 if OOB) |
str_compare(a, b) |
Lexicographic comparison |
How?
Written in BMB — compile-time contracts prove correctness, then generate code faster than hand-tuned C.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bmb_text-0.2.0-py3-none-win_amd64.whl.
File metadata
- Download URL: bmb_text-0.2.0-py3-none-win_amd64.whl
- Upload date:
- Size: 87.9 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd3abab5ce6c7e8c5df2ab79e04fc957032f4755b30199fd96947ec7154ee3ba
|
|
| MD5 |
914b405d210899aa635af06de122828b
|
|
| BLAKE2b-256 |
4571dfaadb89976563804d06a42637cac331cb99c5aa9f5c0e71e452b91f6884
|
File details
Details for the file bmb_text-0.2.0-py3-none-manylinux_2_17_x86_64.whl.
File metadata
- Download URL: bmb_text-0.2.0-py3-none-manylinux_2_17_x86_64.whl
- Upload date:
- Size: 69.3 kB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d06aa52e3732c75505e2367cdf0e935db80303b83d6e09de5fe52fabbb1ce080
|
|
| MD5 |
1fee305354f4188a9d387af3fe0398fd
|
|
| BLAKE2b-256 |
b72ed22df78cacb8842832f0d58cc4a02c64492e746ae2d0d39fd7b79393e4af
|
File details
Details for the file bmb_text-0.2.0-py3-none-macosx_15_0_universal2.whl.
File metadata
- Download URL: bmb_text-0.2.0-py3-none-macosx_15_0_universal2.whl
- Upload date:
- Size: 50.9 kB
- Tags: Python 3, macOS 15.0+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0dd6d05c0b2f669d6abfd14ce42a46bf21186852885a58826ca1ea944d95b5f
|
|
| MD5 |
9e0a3a09e2022008e99f5b268add2f1c
|
|
| BLAKE2b-256 |
ce08a8d22b4c904670704ee3dfefa7f3ccd236fadf4fddf37c9e4c9db3017226
|