All Projects → PHLAK → Twine

PHLAK / Twine

Licence: mit
String manipulation, leveled up!

Projects that are alternatives of or similar to Twine

Cracking The Coding Interview
Solutions for Cracking the Coding Interview - 6th Edition
Stars: ✭ 35 (-92.94%)
Mutual labels:  strings, string-manipulation
Stringz
💯 Super fast unicode-aware string manipulation Javascript library
Stars: ✭ 181 (-63.51%)
Mutual labels:  strings, string-manipulation
Mightystring
Making Ruby Strings Powerful
Stars: ✭ 28 (-94.35%)
Mutual labels:  strings, string-manipulation
Chr
🔤 Lightweight R package for manipulating [string] characters
Stars: ✭ 18 (-96.37%)
Mutual labels:  strings, string-manipulation
Libft
42 library of basic C functions - queues, lists, memory operations and more 😄
Stars: ✭ 21 (-95.77%)
Mutual labels:  strings, string-manipulation
Util
A collection of useful utility functions
Stars: ✭ 201 (-59.48%)
Mutual labels:  strings, string-manipulation
Str
str: yet another string library for C language.
Stars: ✭ 159 (-67.94%)
Mutual labels:  strings, string-manipulation
string theory
Flexible modern C++ string library with type-safe formatting
Stars: ✭ 32 (-93.55%)
Mutual labels:  strings, string-manipulation
bigint
bigint is a C++ library which can handle Very very Big Integers. It can calculate factorial of 1000000... it can go any big. It may be useful in Competitive Coding and Scientific Calculations which deals with very very large Integers. It can also be used in Decryption process. It has many inbuilt functions which can be very useful.
Stars: ✭ 34 (-93.15%)
Mutual labels:  strings, string-manipulation
python-string-utils
A handy Python library to validate, manipulate and generate strings
Stars: ✭ 47 (-90.52%)
Mutual labels:  strings, string-manipulation
the-stringler
An OOP approach to string manipulation.
Stars: ✭ 36 (-92.74%)
Mutual labels:  strings, string-manipulation
Cuerdas
String manipulation library for Clojure(Script)
Stars: ✭ 272 (-45.16%)
Mutual labels:  strings, string-manipulation
js-utils
A collection of dependency-free JavaScript utilities 🔧
Stars: ✭ 22 (-95.56%)
Mutual labels:  strings
Stringr
A fresh approach to string manipulation in R
Stars: ✭ 397 (-19.96%)
Mutual labels:  strings
greek-utils
A JavaScript library for Greek language with utilities such as replacement of accented and other diacritics characters, conversion from Greek to phonetic, transliterated or greeklish Latin and more.
Stars: ✭ 66 (-86.69%)
Mutual labels:  string-manipulation
BhimIntegers
BhimIntegers🚀 is a C++ library that is useful when we are dealing with BigIntegers💥💥. We can handle big integers (integers having a size bigger than the long long int data type) and we can perform arithmetic operations📘 like addition, multiplication, subtraction, division, equality check, etc📐📐. Also, there are several functions like factorial, …
Stars: ✭ 43 (-91.33%)
Mutual labels:  strings
Philology
An easy way to dynamically replace Strings of your Android App or provide new languages Over-the-air without needed to publish a new release on Google Play.
Stars: ✭ 458 (-7.66%)
Mutual labels:  strings
React String Replace
A simple way to safely do string replacement with React components
Stars: ✭ 360 (-27.42%)
Mutual labels:  string-manipulation
indexed-string-variation
Experimental JavaScript module to generate all possible variations of strings over an alphabet using an n-ary virtual tree
Stars: ✭ 16 (-96.77%)
Mutual labels:  strings
string-replace-to-array
Like Javascript's string.replace, but accepts and returns an array
Stars: ✭ 19 (-96.17%)
Mutual labels:  string-manipulation

Twine

String manipulation, leveled up! -- by, Chris Kankiewicz (@PHLAK)

Join our Community Become a Sponsor One-time Donation
Latest Stable Version Total Downloads License Build Status StyleCI


Introduction

Twine is a string manipulation library with an expressive, fluent syntax.

Requirements

Install with Composer

composer require phlak/twine

Getting Started

First, import Twine:

use PHLAK\Twine;

Then instantiate a Twine object by newing up a Twine\Str object and passing your string as the first parameter.

$string = new Twine\Str('john pinkerton');

You may also instantiate a Twine\Str object statically via the make() method.

$string = Twine\Str::make('john pinkerton');

Or use the global str() helper method. The method takes a string as the only parameter and returns a Twine\Str object.

$string = str('john pinkerton');

Once you have a concrete Twine\Str instance you may treat it like any other string. This includes echoing it or using any of PHP's built-in string functions against it.

echo $string; // Echos 'john pinkerton'

str_shuffle($string) // Returns something like 'enoipo ktnjhnr'

strlen($string); // Returns 14

The strength of Twine, however comes from its built-in methods.

$string->echo(); // Echos 'john pinkerton'
$string->shuffle(); // Returns something like 'enoipo ktnjhnr'
$string->length(); // Returns 14

// or some more interesting methods

$string->reverse(); // Returns 'notreknip nhoj'
$string->contains('pink'); // Returns true
$stting->replace('pink', 'purple'); // Returns 'john purpleton'
$string->snakeCase(); // Returns 'john_pinkerton'

At this point you're ready to start using Twine by calling any of its many built-in methods.

Available Methods

afterappendbase64base64Decodebase64EncodebcryptbeforecamelCasecharacterschunkcontainscountcrc32cryptdecryptechoencodingencryptendsWithequalsexplodefirstformatfromhexhexEncodehexDecodeinsensitiveMatchinsertinisAlphabeticisAlphanumericisEmptyisLowercaseisNotEmptyisNumericisPrintableisPunctuationisUppercaseisWhitespacejoinkebabCaselastlengthlowercaselowercaseFirstlowercaseWordsmatchmatchAllmatchesmd5nthpadpadBothpadLeftpadRightpascalCaseprependrepeatreplacereversesha1sha256shufflesimilaritysnakeCasesplitstartsWithstripstudlyCasesubstringtotrimtrimLefttrimRighttruncateuppercaseuppercaseFirstuppercaseWordsurlwordswrapwrapHardwrapSoft


Method Chaining

A Twine string can be manipulated fluently by chaining methods. Here are a few example chains:

Perform a substring comparison:

$string = new Twine\Str('john pinkerton');

$string->substring(5, 4)->equals('pink'); // Returns true

Encode a file in compliance with RFC 2045.

$string = new Twine\Str(file_get_contents('garbage.bin'));

$string->base64()->wrap(76, "\r\n", Twine\Config\Wrap::HARD);

Additional details available in the full documentation at https://twine.phlak.net.

MultiByte Strings

Twine aims for mltibyte string compatibility by relying on PHP's Multibyte String extension (mbstring) to perform string operations. For this reason, the mbstring extension is required. Multibyte strings include Unicode encodings such as UTF-8 and UCS-2.

Changelog

A list of changes can be found on the GitHub Releases page.

Troubleshooting

For general help and support join our Spectrum community or reach out on Twitter.

Please report bugs to the GitHub Issue Tracker.

Copyright

This project is licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].