Instructor: The Dart toolbox contains utility methods for working with strings as part of the dart:core library. Use the contains method to check whether the specified text exists. You can pass in a regular expression to enhance your search.
To check whether the string starts with a particular character or set of characters, use the startsWith method. To check whether the string ends with a particular character or set of characters, use the endsWith method.
To convert the string to its uppercase and lowercase formats, use the toUpperCase and toLowerCase methods. Strings can also be split into an array of strings using the split method and passing it a delimiter.
Use the splitMapJoin method to split a string into an array of strings, perform transformation on each item, and return the joined output. The first argument takes a pattern to match for. The second argument is a named parameter called onMatch, which allows us to perform transformation on our matched pattern.
The third argument is a named parameter which allows us to perform transformations on non-matches. You can enable the multiline option for our regex if you wish to affect each line.
To retrieve the positions of the first and last matches of a particular string, use the indexOf and lastIndexOf methods. Use the trim method to remove any leading and trailing white spaces. Here's what it looks like without using the trim method. You can pad a string using the padLeft and padRight methods if the string length is less than the specified value.
Last but not least, you can replace a part of the string that matches the specified pattern. Here is how to do the same using a regular expression. If you wish to retain any captured groups from your regular expressions, use the replaceAllMapped method. Then we'll wrap the first captured group in the curved braces. This concludes our lesson.