Skip to content

Latest commit

 

History

History
100 lines (68 loc) · 3.19 KB

README.md

File metadata and controls

100 lines (68 loc) · 3.19 KB

Swift String Helper

This is a Swift package that provides a fluent, convenient extensions for working with and manipulating String in a more elegant and expressive manner.

Platform GitHub release (latest by date) GitHub

Installation

  1. Open your existing Xcode project or create a new one.
  2. In the Xcode menu, go to File > Add Packages....
  3. In the Search or Enter Package URL field, enter: https://github.com/rkukuh/Swift-StringHelper.git.
    Press Return to load the package.
  4. After the package is loaded, you will see the package details, including its name, the repository URL, and available versions.
    By default, Xcode selects the most recent version. You can choose a specific version, a branch, or a commit using the provided options.
  5. Click Add Package to confirm the addition of the package to your project.
  6. Xcode will download the package and add it to your project's Swift Package Dependencies.
    You can check this by going to your project settings and selecting the Package Dependencies tab.
  7. To use the package in your project, simply import the package module at the top of any Swift file where you want to use it:
import SwiftStringHelper

//...

Available Methods

These following methods are available for working with and manipulating String native library.

Usage

after

The after() helper returns the remainder of a string after the first occurrence of a given value.

let originalString = "[email protected]"
let result = originalString.after("@")

print(result) // apple.com

before

The before() helper returns the portion of a string before the first occurrence of a given value.

let originalString = "[email protected]"
let result = originalString.before("@")

print(result) // john

between

The between() helper returns the portion of a string between two values.

let originalString = "[email protected]"
let result = originalString.between("john@", and: ".com")

print(result) // Optional("apple")

camelCase

The camelCased() helper converts the given string to camelCaseLikeThis.

var originalString = "Everyone CAN Code"
var result = originalString.camelCased()

print(result) // everyoneCanCode

containsAll

The containsAll() helper determines if the given string contains all of the values in a given array.

let originalString = "[email protected]"
let result = originalString.containsAll(["hello", "@", ".com"])

print(result) // true
let originalString = "[email protected]"
let result = originalString.containsAll(["hello", "@", ".org"])

print(result) // false