Skip to main content

Find common prefix of strings, tuples, and nested structures

Project description

k3pattern

Action-CI Build Status Documentation Status Package

Find common prefix of several strings, tuples of string, or other nested structure, recursively by default.

k3pattern is a component of pykit3 project: a python3 toolkit set.

Find common prefix of several string, tuples of string, or other nested structure, recursively by default. It returns the shortest prefix: empty string or empty tuple is removed.

Install

pip install k3pattern

Synopsis

import k3pattern

k3pattern.common_prefix('abc', 'abd')                   # 'ab'
k3pattern.common_prefix((1, 2, 'abc'), (1, 2, 'abd'))   # (1, 2, 'ab')
k3pattern.common_prefix((1, 2, 'abc'), (1, 2, 'xyz'))   # (1, 2); empty prefix of 'abc' and 'xyz' is removed
k3pattern.common_prefix((1, 2, (5, 6)), (1, 2, (5, 7))) # (1, 2, (5,) )
k3pattern.common_prefix('abc', 'abd', 'abe')            # 'ab'; common prefix of more than two

Author

Zhang Yanpo (张炎泼) drdr.xp@gmail.com

Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) drdr.xp@gmail.com

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

k3pattern-0.1.2.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

k3pattern-0.1.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file k3pattern-0.1.2.tar.gz.

File metadata

  • Download URL: k3pattern-0.1.2.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for k3pattern-0.1.2.tar.gz
Algorithm Hash digest
SHA256 fc6d46dab2b06350748bfbcfbbbe2ed4770ed21475214f3c0d0e2277a6b0a7b2
MD5 dc3aab93c498ed719a4607f7e8bddc24
BLAKE2b-256 52cdb69ef64db0e3d736942f7de9fdb24939b3c61af357e1c4021806d839c387

See more details on using hashes here.

File details

Details for the file k3pattern-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: k3pattern-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for k3pattern-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c13e230d6060d5e3a53e0270dc314187bb6fd7efc1d5bc281e327ef44f5d8831
MD5 804fea10d868aa8621949d77646b4b00
BLAKE2b-256 6c293eb7d1832a25497331ac817e521967703c5aaf3076d8ff69ad42b3bc1ae4

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