GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Meniny/Substring: Substring with without boilerplate, verbose and complex code.

BranchesTags
Open more actions menu

Latest commit

 

History

5 Commits
5 Commits

Folders and files

NameName
Last commit message
Last commit date
Sample
Sample
 
 
Substring
Substring
 
 
.gitignore
.gitignore
 
 
LICENSE.md
LICENSE.md
 
 
README.adoc
README.adoc
 
 
Substring.podspec
Substring.podspec
 
 
_config.yml
_config.yml
 
 

Repository files navigation

Meet Substring

Substring

Author EMail MIT
Version Platforms Swift
Build Passing Cocoapods Carthage SPM

🏵 Introduction

Substring is a tiny library allows you to substring without boilerplate, verbose and complex code.

The strings management of Swift is one of the most painful feature ever:

let string = "Substring API sucks!"
let start = string.index(string.startIndex, offsetBy: 1)
let end = string.index(string.startIndex, offsetBy: 6)
let substring = String(string[start..<end])

No! Stop it!

Now with this tiny library called Substring, you can simplly do this:

let substring = string[1..<6].string

Or this, if you prefer:

let substring = string.substring(in: 1..<6).string

Learn more.

📋 Requirements

Type Requirement

Platform

iOS

8.0+

macOS

10.9

tvOS

9.0

watchOS

2.0

Linux

✔

IDE

Xcode

10.2+

Language

Swift

5+

📲 Installation

CocoaPods

Substring is available on CocoaPods.

use_frameworks!
pod 'Substring'

Manually

Copy all files in the Substring directory into your project.

🛌 Dependency

N/A

❤️ Contribution

You are welcome to fork and submit pull requests.

🔖 License

Substring is open-sourced software, licensed under the MIT license.

🔫 Usage

import Substring

let string = "A_Example_String"

// STR: A _ E x a m p l e _ S  t  r  i  n  g
// IDX: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

print(string.substring(at: 1).string, string[1].string) // "_"
print(string.substring(to: 4).string, string[...4].string) // "A_Exa"
print(string.substring(from: 2).string, string[2...].string) // "Example_String"
print(string.substring(before: 5).string, string[..<5].string) // "A_Exa"
print(string.substring(in: 2...5).string, string[2...5].string) // "Exam"
print(string.substring(in: 2..<5).string, string[2..<5].string) // "Exa"

// ...

About

Substring with without boilerplate, verbose and complex code.

Topics

substring

Resources

Readme
MIT license
Activity

Stars

6 stars

Watchers

2 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.