Skip to main content

Better String Operations

Project description

Overview

Complex lines of code for manipulating strings are no more.

Table of Contents

Installation

Installation is pretty easy.

pip install stringops

Usage

Manipulation

Import the necessary extended class

from stringops.manipulation import Manipulation

Manipulate -> add

# suppose there is some string say 'value'

value = "Hey This is me"

# I want to add a '.' at the end

value = Manipulation(value)
value = value.add(".")

# I also want to add another sentence to it.

value = value.add("How are you", "!")

# print it
print(value)

Manipulate -> half

# lets take the above variable 'value'.

value = Manipulation("hey, this is me")

# I want to divide the string into half and i want to get the left side of the result.

left_half = value.half("left")
right_half = value.half("right")

print(left_half, right_half)

Manipulate -> split

# using the same varibale 'value'.

value = Manipulation("hey, this is me")

# suppose i want to split the string based on white spaces and
# get the value that is in the index place of 1

# can be done using
# >>> value.split(" ")[1]

index_one_value: str = value.split(" ", 1)

# all the values can also be retrieved
all_values: list[str] = value.split(" ", "all")

CONVERT THIS MANIPULATION OBJECT TO READ

value: Manipulation = Manipulation("hey, this is me")
value: Read = value.convert_to_read()

Read

Importing

from stringops.read import Read

Read - check substring

value = Read("hey, this is me")

if value.there("he"):
    return True
else:
    return False

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

stringops-1.1.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

stringops-1.1-py3-none-any.whl (5.4 kB view hashes)

Uploaded Python 3

Supported by

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