Search code examples
crystal-lang

How to check if a string is contained in a substring in Crystal Lang?


I don't see a String#contains method or a String#search method in the Crystal API.


Solution

  • There is String#includes? which checks if the search exists in the string and returns a bool or String#index which returns the index of the search if it exists.