Skip to content

Latest commit

 

History

History
151 lines (101 loc) · 2.55 KB

strings.md

File metadata and controls

151 lines (101 loc) · 2.55 KB

Strings

{id: strings}

Strings intro

{id: strings-intro}

Length or size of a string

{id: strings-length} {i: size} {i: length}

Locate substring (index, rindex)

{id: strings-index} {i: index} {i: rindex}

Reverse a string

{id: strings-revers} {i: reverse}

  • The original string stays intact

Substring, range of characters

{id: substring}

String includes another string

{id: strings-includes-another-string} {i: includes?}

String starts with

{id: strings-starts-with} {i: starts_with}

String ends with

{id: strings-ends-with} {i: ends_with}

Replace part of a string (substitute)

{id: strings-substitute} {i: sub}

  • If there is nothing to replace, nothing happens
  • Only replaces the first occurrence of the string

Is the string empty or blank?

{id: strings-empty} {i: size} {i: empty?} {i: blank?}

Iterate over characters of a string

{id: strings-iterator} {i: each_char}

Type conversion from string to float, to int

{id: type-conversion} {i: to_f} {i: to_i}

Converting string to integer or float

{id: converting-string-to-integer-or-float} {i: to_i} {i: to_i?} {i: to_f} {i: to_f?}

Split String

{id: split-string} {i: split}

String Transliteration

{id: string-transliteration} {i: tr}

String Builder

{id: string-builder}

sprintf and %

{id: string-sprintf}

Split to the same string length

{id: split-to-fixed-width}

Split characters

{id: split-characters} {i: split} {i: chars}

printf

{id: printf} {i: printf}

Here documents

{id: here-documents} {i: <<-}