EnchantedStringRegexExtension extension

on

Methods

forEachNamedGroup(RegExp regex, {required void onMatch(FindedGroup group), void onNonMatch(NonMapContent textContext)?, bool willContainBeforeAndAfterContentAsNonMatch = true}) → void

Available on String, provided by the EnchantedStringRegexExtension extension

For each named group found in the text with the regex, will call the onGroupFind with the FindedGroup.
forEachNamedGroupMapper(RegExp regex, {required void onGroupFind(FindedGroup group, bool isFirst, bool isLast, int index, int matchsFinded, int groupsInCurrentMatch, int currentIndexInsideMatchsFindedLoop)}) → void

Available on String, provided by the EnchantedStringRegexExtension extension

Really close to what forEachNamedGroup does, but with more parameters to help you to know where you are in the list loop iteration.
Such as:
mapSeparateStats<T>(List<FindedGroup> groups, {required T onMatch(FindedGroup group), required T onNonMatch(String text)}) List<T>

Available on String, provided by the EnchantedStringRegexExtension extension

replaceAllNamedGroups(RegExp regex, {required String onMatch(FindedGroup group)}) String

Available on String, provided by the EnchantedStringRegexExtension extension

Similar to String.replaceAllMapped, but using FindedGroup instead of Match on "onMatch" function.
splitMapCast<T>(RegExp pattern, {required T onMatch(Match group), required T onNonMatch(String text)}) List<T>

Available on String, provided by the EnchantedStringRegexExtension extension

Similar to splitMapJoin, but instead of returning a string will return whatever you want. So for each match or non match, you can return the type
splitMapNamedGroupCast<T>(RegExp regex, {required T onMatch(FindedGroup group), required T onNonMatch(String text), bool willContainBeforeAndAfterContentAsNonMatch = true}) List<T>

Available on String, provided by the EnchantedStringRegexExtension extension

Equal to splitMapCast, but instead of onMatch using a Match class will use a FindedGroup class.