Dart String Manipulations:

Dart String Manipulations:

Length:

  • Length method is use for the measure the length of any string.

Substring:

  • Substring method use for print string using index.

  • In below example you can see the syntax of substring.

  • (3, 6 ) here, 3 is staring index and 6 is the ending index.

Uppercase & Lowercase:

  • Like the name , you can guess it that this both methods is use for the change case.

Split & Join:

  • This method use to separate string and join the string without using any other method like concertation for join string .

Trimming & Padding:

  • Trimming refers to the removal of certain characters, usually whitespace, from the beginning and end of a string.

  • Padding involves adding characters, often spaces or a specific character, to the beginning and end of a string to achieve a desired length.

  • You can also use a custom character for padding by providing it as the second argument to padLeft() and padRight().

Replacing:

  • To replace all occurrences of a substring in a string, you can use the replaceAll method.

String Buffer:

  • This method use for as a storage , we can create one variable and using write method we can write different type string and Int in the variable and in the last it will print all the string and int value whichever store in message variable , for this we just need to write StringBuffer() .

Build Strings in Loop:

String Validations: startsWith(), endsWith() and contain()

  • This method use for validate the value and it give output in only boolean.

  • There are total 3 method to validate .

  • First one is .startsWith();

  • Second one is .endsWith();

  • And the Last one is .contains();

String RegExp:

  • In Dart, regular expressions (regex or regexp) are represented by the RegExp class. Dart provides support for regular expressions through the RegExp class in the dart:core library. Here is example demonstrating how to use regular expressions in Dart:

  • In this example, we create a regular expression RegExp(r"is") to match the substring "is". The hasMatch method is then used to check if the regular expression has a match in the given text.