Reputation: 6766
How can I pull out a string from two different patterns either side of the string I want: eg
String s= bg_img_pulloutthisstring@s_200
How can I pull out pulloutthisstring
from s?
Upvotes: 0
Views: 97
Reputation: 31209
The easiest is to use a Regular Expression and use a match group:
void main() {
const s = 'bg_img_pulloutthisstring@s_200';
print(RegExp(r'bg_img_(.*)@s_200').firstMatch(s).group(1)); // pulloutthisstring
}
Upvotes: 1