Yes. I have not used it before, but I gave it a try now:
$ expo install string.prototype.matchall
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import matchAll from 'string.prototype.matchall';
export default function App() {
// from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll
// with str.matchAll(...) converted to matchAll(str, ...)
const regexp = /t(e)(st(\d?))/g;
const str = 'test1test2';
const array = [... matchAll(str, regexp)];
console.log(array[0]);
// expected output: Array ["test1", "e", "st1", "1"]
console.log(array[1]);
// expected output: Array ["test2", "e", "st2", "2"]
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Output:
Array [
"test1",
"e",
"st1",
"1",
]
Array [
"test2",
"e",
"st2",
"2",
]