Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

String Methods

  • contains
  • indexOf
  • replaceAll
  • RegExp
main () {
  var str = "The black cat climbed the green tree.";
  print(str.contains('The'));                    // true
  print(str.contains('The', 1));                 // false
  print(str.contains(new RegExp(r'dog|cat')));   // true
  
  print(str.indexOf(new RegExp(r'dog|cat'), 2)); // 10
  print(str.indexOf('dog'));                     // -1
  
  print(str.replaceAll('climbed', 'jumped from'));
  print(str);
  
}