Home > Mobile >  Get text String in Between two Strings (keywords) - in Dart - Flutter
Get text String in Between two Strings (keywords) - in Dart - Flutter

Time:10-14

I'm currently using this function bellow to capture text after a certain keyword in a String of text :

      static String? _getTextAfterKeyword({
    required String inputtext,
    required String keyword,
  }) {
    final indexKeyword = text.indexOf(keyword);
    final indexAfter = indexKeyword   keyword.length;

    if (indexKeyword == -1) {
      return null;
    } else {
      return text.substring(indexAfter).trim();
    }
  }

Now I'm trying to capture a String of text in between two keywords - but what I've tried hasn't worked -

  • Related