class String
- String
- Reference
- Object
Overview
Extend ::String class to check if a string is numeric
Included Modules
- Comparable(String)
Defined in:
analyzer/analyzers/python/fastapi.crext/string_search.cr
utils/string_extension.cr
Instance Method Summary
-
#byte_index(search : String, offset = 0) : Int32 | Nil
Returns the byte index of search in the string, or
nilif the string is not present. - #gsub_repeatedly(pattern, replacement)
-
#index(search : String, offset = 0) : Int32 | Nil
Returns the index of the first occurrence of search in the string, or
nilif not present. - #numeric?
Instance Method Detail
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
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