Reputation: 4810
Java script regular expression
/\d(.*)\s[0-9A-Z:]{17}/i
Test Case
console.log("11 salus_biura 68:d7:9a:da:7d:6a WPA2PSK/AES 29 11b/g/n NONE In NO ".match(/\d(.*)\s[0-9A-Z:]{17}/i)[1]);
Dart code
void main() {
String wifiInfo = "11 salus_biura 68:d7:9a:da:7d:6a WPA2PSK/AES 29 11b/g/n NONE In NO ";
Match? matches = RegExp(r'\\d(.*)\\s[0-9A-Z:]{17}', caseSensitive: true).firstMatch(wifiInfo);
print(matches?.group(1)); // null
}
issue {17} Matches exactly not work
output in dart 1 salus_biura
Upvotes: 1
Views: 162
Reputation: 626748
In your Dart code,
caseSensitive: true
as you have an i
flag (that enables case insensitive matching) in your JavaScript regex"\\d"
= r"\d"
.The fix code can look like
void main() {
String wifiInfo = "11 salus_biura 68:d7:9a:da:7d:6a WPA2PSK/AES 29 11b/g/n NONE In NO ";
Match? matches = RegExp(r'\d(.*)\s[0-9A-Z:]{17}', caseSensitive: false).firstMatch(wifiInfo);
print(matches?.group(1)); // => 1 salus_biura
}
Upvotes: 3