contains_text

From Kolmafia
Jump to navigation Jump to search

Function Syntax

boolean contains_textstring str, string substring )

Returns true if the first string contains the second string.
  • str: String to search in
  • substring: Substring to check for

Code Samples

This function checks whether the string "Hello World!" contains the word "World".

boolean string_check()
{
   if ( contains_text("Hello World!" , "World" ) )
   {
      return true;
   }
   return false;
}

This function checks whether a character is in a clan.

boolean in_clan()
{
   string character = visit_url( "showplayer.php?who=" + my_id().to_string() );
   if ( contains_text( character , "showclan.php?whichclan" ) )
   {
      return true;
   }
   return false;
}

Or this, more concise version...

boolean in_clan()
{
   return contains_text( visit_url( "showplayer.php?who=" + my_id().to_string() ), "showclan.php?whichclan" );
}

See Also

contains_text() | ends_with() | index_of() | last_index_of() | starts_with()