'flutter check if string starts with RegExp
in flutter if we want to check if a string starts with a specific character...we can achieve that by:
var string = 'Dart';
string.startsWith('D'); // true
what if we want to check if the given string starts with multiple characters....i want to achieve this behaviour:
RegExp myRegExp = ('a-zA-Z0-9');
var string = 'Dart';
string.startsWith('D' + myRegExp);
is the above code is right?!!
my goal is to check if the string starts with a letter i specify...then a RegExp.... not to check if the string starts with 'D' only and thats it...
Solution 1:[1]
I think you'll want something like string.startsWith(RegExp('D' + '[a-zA-Z0-9]'));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Randal Schwartz |
