class String

Overview

Extend ::String class to check if a string is numeric

Included Modules

Defined in:

analyzer/analyzers/python/fastapi.cr
ext/string_search.cr
utils/string_extension.cr

Instance Method Summary

Instance Method Detail

def byte_index(search : String, offset = 0) : Int32 | Nil #

Returns the byte index of search in the string, or nil if the string is not present. If offset is present, it defines the position to start the search.

Negative offset can be used to start the search from the end of the string.

"¥hello".byte_index("hello")              # => 2
"hello".byte_index("world")               # => nil
"Dizzy Miss Lizzy".byte_index("izzy")     # => 1
"Dizzy Miss Lizzy".byte_index("izzy", 2)  # => 12
"Dizzy Miss Lizzy".byte_index("izzy", -4) # => 12
"Dizzy Miss Lizzy".byte_index("izzy", -3) # => nil

[View source]
def gsub_repeatedly(pattern, replacement) #

[View source]
def index(search : String, offset = 0) : Int32 | Nil #

Returns the index of the first occurrence of search in the string, or nil if not present. If offset is present, it defines the position to start the search.

"Hello, World".index('o')    # => 4
"Hello, World".index('Z')    # => nil
"Hello, World".index("o", 5) # => 8
"Hello, World".index("H", 2) # => nil
"Hello, World".index(/[ ]+/) # => 6
"Hello, World".index(/\d+/)  # => nil

[View source]
def numeric? #

[View source]