Latest 2.2.1
Homepage https://github.com/visualNACert/StringUtilities
License LGPL2
Platforms ios 8.0, osx 10.10
Authors ,

Build Status codecov documentation pod platforms pod version pod license

String Utilities

This is a small collection of utilities to work with strings easily, including:

  • Removing multiple occurrences of multiple strings.
  • Retrieving regex capture groups.
  • Trimming strings.

API


// Range based subscript...
let string = "Lorem ipsum dolor sit amet"
let lorem = string[0..<5]

// Readable join...
let characters = ["Obi Wan-Kenobi", "Darth Vader", "Luke Skywalker"]
print(characters..joined(separator: ", ", lastElementSeparator: " and "))
// Obi Wan-Kenobi, Darth Vader and Luke Skywalker

// Remove substrings...
let string = "Lorem ipsum dolor sit amet"
let withoutLorem = string.removing("Lorem")
let withoutVowels = string.removing(["a", "e", "i", "o", "u"])

// Trim...
let string = "Lorem ipsum dolor sit amet   "
print(string.trimmed) // Lorem ipsum dolor sit amet

// Regex...
let html = "<img src="image_src" title="An image" alt="Some text" />"

let matches = try! html.matches(for: "<img.*src=\"([^"]*)\".*\/>")

print(matches[0]) // <img src="image_src" title="An image" alt="Some text" />
print(matches[1]) // image_src

Latest podspec

{
    "name": "StringUtilities",
    "version": "2.2.1",
    "summary": "A collection of utilities to work with strings",
    "description": "Collection of utilities to work with strings, including regex helpers andntrimming methods",
    "homepage": "https://github.com/visualNACert/StringUtilities",
    "license": {
        "type": "LGPL2",
        "file": "LICENSE"
    },
    "authors": {
        "visualNACert team": "",
        "Lluu00eds Ulzurrun de Asanza i Su00e0ez": "[email protected]"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.10"
    },
    "source": {
        "git": "https://github.com/visualNACert/StringUtilities.git",
        "tag": "2.2.1"
    },
    "source_files": [
        "Source",
        "Source/**/*.{h,m,swift}"
    ],
    "exclude_files": "Source/Exclude",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This