0

Im trying to find if string match a regex on Dart.

My string is:

text text text ... ... ... 
 <iframe class="embedly-embed" src="https://api.com" scrolling="no" frameborder="0" allowfullscreen=""></iframe>
 text text text ... ... ... 

my regex is:

  RegExp exp2 =
      new RegExp(r'<iframe.*class=\"embedly-embed\".*src=\"(.+?)\"');

when im using https://regex101.com/r/24KmKH/4 the regex work correctly.

when im tying using Dart, the regex works only like this:

      RegExp exp3 = new RegExp(r'<iframe.*class=');

how can i get only the src (https://api.com) link if it matches the regex using Dart ?

Eden Nahum
  • 75
  • 1
  • 5
  • `match.group(1)` – Wiktor Stribiżew Nov 29 '20 at 21:26
  • [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: RangeError: Value not in range: 1 – Eden Nahum Nov 29 '20 at 21:39
  • 1
    No, if you have a regex as you showed with a capturing group and you have a match, all should work well. If it does not, please add all the relevant code into the question to see what goes wrong. Also, do not forget to share the exact *text* you run your regex against. – Wiktor Stribiżew Nov 29 '20 at 21:50

0 Answers0