Flutter cannot parse regex
Flutter cannot parse this working regex, and doesn't return any error or info.
(?<=id=)[^&]+
However, when I add it into my Flutter app:
print("before");
new RegExp(r'(?<=id=)[^&]+');
print("after");
It doesn't do anything, doesn't return any error. The print("after");
never gets executed. It doesn't completly freeze the app, because it's in async.
regex dart

add a comment |
Flutter cannot parse this working regex, and doesn't return any error or info.
(?<=id=)[^&]+
However, when I add it into my Flutter app:
print("before");
new RegExp(r'(?<=id=)[^&]+');
print("after");
It doesn't do anything, doesn't return any error. The print("after");
never gets executed. It doesn't completly freeze the app, because it's in async.
regex dart

add a comment |
Flutter cannot parse this working regex, and doesn't return any error or info.
(?<=id=)[^&]+
However, when I add it into my Flutter app:
print("before");
new RegExp(r'(?<=id=)[^&]+');
print("after");
It doesn't do anything, doesn't return any error. The print("after");
never gets executed. It doesn't completly freeze the app, because it's in async.
regex dart

Flutter cannot parse this working regex, and doesn't return any error or info.
(?<=id=)[^&]+
However, when I add it into my Flutter app:
print("before");
new RegExp(r'(?<=id=)[^&]+');
print("after");
It doesn't do anything, doesn't return any error. The print("after");
never gets executed. It doesn't completly freeze the app, because it's in async.
regex dart

regex dart

edited Jan 2 at 7:49
Wiktor Stribiżew
324k16146226
324k16146226
asked Dec 31 '18 at 10:34
Makalone LOgmanMakalone LOgman
1078
1078
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Dart compiled for the Web supports lokbehinds, but the current version of native Dart (including Flutter) does not support lookbehinds (source).
In your case, you want to match a string after a specific string. All you need is to declare a capturing group in your pattern and then access that submatch:
RegExp regExp = new RegExp(r"id=([^&]+)");
String s = "http://example.com?id=some.thing.com&other=parameter; http://example.com?id=some.thing.com";
Iterable<Match> matches = regExp.allMatches(s);
for (Match match in matches) {
print(match.group(1));
}
Output:
some.thing.com
some.thing.com
Here, id=([^&]+)
matches id=
and then the ([^&]+)
capturing group #1 matches and captures into Group 1 any one or more chars other than &
. Note you may make it safer if you add [?&]
before id
to only match id
and not thisid
query param: [?&]id=([^&]+)
.
add a comment |
I assume this is https://github.com/dart-lang/sdk/issues/34935
Bring Dart's RegExp support in line with JavaScript: lookbehinds, property escapes, and named groups.
So... Its not supported in current version of Flutter? So I will have to use justid=[^&]+
and then ReplaceAllid=
with''
.
– Makalone LOgman
Dec 31 '18 at 10:40
1
Yes, Flutter depends on Dart for RegExp and Dart limits itself to what is supported in the browser, but they are a bit behind, because I think your example is now supported in recent browser versions, but not yet in Dart. I don't have deep RegExp knowledge and I'm not sure what a good workaround would be.
– Günter Zöchbauer
Dec 31 '18 at 10:47
Ok, thanks then.
– Makalone LOgman
Dec 31 '18 at 11:15
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53986424%2fflutter-cannot-parse-regex%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Dart compiled for the Web supports lokbehinds, but the current version of native Dart (including Flutter) does not support lookbehinds (source).
In your case, you want to match a string after a specific string. All you need is to declare a capturing group in your pattern and then access that submatch:
RegExp regExp = new RegExp(r"id=([^&]+)");
String s = "http://example.com?id=some.thing.com&other=parameter; http://example.com?id=some.thing.com";
Iterable<Match> matches = regExp.allMatches(s);
for (Match match in matches) {
print(match.group(1));
}
Output:
some.thing.com
some.thing.com
Here, id=([^&]+)
matches id=
and then the ([^&]+)
capturing group #1 matches and captures into Group 1 any one or more chars other than &
. Note you may make it safer if you add [?&]
before id
to only match id
and not thisid
query param: [?&]id=([^&]+)
.
add a comment |
Dart compiled for the Web supports lokbehinds, but the current version of native Dart (including Flutter) does not support lookbehinds (source).
In your case, you want to match a string after a specific string. All you need is to declare a capturing group in your pattern and then access that submatch:
RegExp regExp = new RegExp(r"id=([^&]+)");
String s = "http://example.com?id=some.thing.com&other=parameter; http://example.com?id=some.thing.com";
Iterable<Match> matches = regExp.allMatches(s);
for (Match match in matches) {
print(match.group(1));
}
Output:
some.thing.com
some.thing.com
Here, id=([^&]+)
matches id=
and then the ([^&]+)
capturing group #1 matches and captures into Group 1 any one or more chars other than &
. Note you may make it safer if you add [?&]
before id
to only match id
and not thisid
query param: [?&]id=([^&]+)
.
add a comment |
Dart compiled for the Web supports lokbehinds, but the current version of native Dart (including Flutter) does not support lookbehinds (source).
In your case, you want to match a string after a specific string. All you need is to declare a capturing group in your pattern and then access that submatch:
RegExp regExp = new RegExp(r"id=([^&]+)");
String s = "http://example.com?id=some.thing.com&other=parameter; http://example.com?id=some.thing.com";
Iterable<Match> matches = regExp.allMatches(s);
for (Match match in matches) {
print(match.group(1));
}
Output:
some.thing.com
some.thing.com
Here, id=([^&]+)
matches id=
and then the ([^&]+)
capturing group #1 matches and captures into Group 1 any one or more chars other than &
. Note you may make it safer if you add [?&]
before id
to only match id
and not thisid
query param: [?&]id=([^&]+)
.
Dart compiled for the Web supports lokbehinds, but the current version of native Dart (including Flutter) does not support lookbehinds (source).
In your case, you want to match a string after a specific string. All you need is to declare a capturing group in your pattern and then access that submatch:
RegExp regExp = new RegExp(r"id=([^&]+)");
String s = "http://example.com?id=some.thing.com&other=parameter; http://example.com?id=some.thing.com";
Iterable<Match> matches = regExp.allMatches(s);
for (Match match in matches) {
print(match.group(1));
}
Output:
some.thing.com
some.thing.com
Here, id=([^&]+)
matches id=
and then the ([^&]+)
capturing group #1 matches and captures into Group 1 any one or more chars other than &
. Note you may make it safer if you add [?&]
before id
to only match id
and not thisid
query param: [?&]id=([^&]+)
.
answered Dec 31 '18 at 12:15
Wiktor StribiżewWiktor Stribiżew
324k16146226
324k16146226
add a comment |
add a comment |
I assume this is https://github.com/dart-lang/sdk/issues/34935
Bring Dart's RegExp support in line with JavaScript: lookbehinds, property escapes, and named groups.
So... Its not supported in current version of Flutter? So I will have to use justid=[^&]+
and then ReplaceAllid=
with''
.
– Makalone LOgman
Dec 31 '18 at 10:40
1
Yes, Flutter depends on Dart for RegExp and Dart limits itself to what is supported in the browser, but they are a bit behind, because I think your example is now supported in recent browser versions, but not yet in Dart. I don't have deep RegExp knowledge and I'm not sure what a good workaround would be.
– Günter Zöchbauer
Dec 31 '18 at 10:47
Ok, thanks then.
– Makalone LOgman
Dec 31 '18 at 11:15
add a comment |
I assume this is https://github.com/dart-lang/sdk/issues/34935
Bring Dart's RegExp support in line with JavaScript: lookbehinds, property escapes, and named groups.
So... Its not supported in current version of Flutter? So I will have to use justid=[^&]+
and then ReplaceAllid=
with''
.
– Makalone LOgman
Dec 31 '18 at 10:40
1
Yes, Flutter depends on Dart for RegExp and Dart limits itself to what is supported in the browser, but they are a bit behind, because I think your example is now supported in recent browser versions, but not yet in Dart. I don't have deep RegExp knowledge and I'm not sure what a good workaround would be.
– Günter Zöchbauer
Dec 31 '18 at 10:47
Ok, thanks then.
– Makalone LOgman
Dec 31 '18 at 11:15
add a comment |
I assume this is https://github.com/dart-lang/sdk/issues/34935
Bring Dart's RegExp support in line with JavaScript: lookbehinds, property escapes, and named groups.
I assume this is https://github.com/dart-lang/sdk/issues/34935
Bring Dart's RegExp support in line with JavaScript: lookbehinds, property escapes, and named groups.
answered Dec 31 '18 at 10:37


Günter ZöchbauerGünter Zöchbauer
332k701006941
332k701006941
So... Its not supported in current version of Flutter? So I will have to use justid=[^&]+
and then ReplaceAllid=
with''
.
– Makalone LOgman
Dec 31 '18 at 10:40
1
Yes, Flutter depends on Dart for RegExp and Dart limits itself to what is supported in the browser, but they are a bit behind, because I think your example is now supported in recent browser versions, but not yet in Dart. I don't have deep RegExp knowledge and I'm not sure what a good workaround would be.
– Günter Zöchbauer
Dec 31 '18 at 10:47
Ok, thanks then.
– Makalone LOgman
Dec 31 '18 at 11:15
add a comment |
So... Its not supported in current version of Flutter? So I will have to use justid=[^&]+
and then ReplaceAllid=
with''
.
– Makalone LOgman
Dec 31 '18 at 10:40
1
Yes, Flutter depends on Dart for RegExp and Dart limits itself to what is supported in the browser, but they are a bit behind, because I think your example is now supported in recent browser versions, but not yet in Dart. I don't have deep RegExp knowledge and I'm not sure what a good workaround would be.
– Günter Zöchbauer
Dec 31 '18 at 10:47
Ok, thanks then.
– Makalone LOgman
Dec 31 '18 at 11:15
So... Its not supported in current version of Flutter? So I will have to use just
id=[^&]+
and then ReplaceAll id=
with ''
.– Makalone LOgman
Dec 31 '18 at 10:40
So... Its not supported in current version of Flutter? So I will have to use just
id=[^&]+
and then ReplaceAll id=
with ''
.– Makalone LOgman
Dec 31 '18 at 10:40
1
1
Yes, Flutter depends on Dart for RegExp and Dart limits itself to what is supported in the browser, but they are a bit behind, because I think your example is now supported in recent browser versions, but not yet in Dart. I don't have deep RegExp knowledge and I'm not sure what a good workaround would be.
– Günter Zöchbauer
Dec 31 '18 at 10:47
Yes, Flutter depends on Dart for RegExp and Dart limits itself to what is supported in the browser, but they are a bit behind, because I think your example is now supported in recent browser versions, but not yet in Dart. I don't have deep RegExp knowledge and I'm not sure what a good workaround would be.
– Günter Zöchbauer
Dec 31 '18 at 10:47
Ok, thanks then.
– Makalone LOgman
Dec 31 '18 at 11:15
Ok, thanks then.
– Makalone LOgman
Dec 31 '18 at 11:15
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53986424%2fflutter-cannot-parse-regex%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown