How to match negative lookbehind with unknown characters between?How do you access the matched groups in a JavaScript regular expression?Javascript: negative lookbehind equivalent?How to get first character of string?Regex Match all characters between two stringsHow to match “anything up until this sequence of characters” in a regular expression?Negative Lookbehind: Match a substring that's not preceded one of a set of charactersNegative lookbehind regex (PERL) with variable characters in-betweenignore preceding spaces using negative lookbehindNegative Lookbehind not negating entire matchHow to match a regex pattern with negative lookbehind on JavaScript?
Being told my "network" isn't PCI compliant. I don't even have a server! Do I have to comply?
Has J.J.Jameson ever found out that Peter Parker is Spider-Man?
Need reasons why a satellite network would not work
How to handle many times series?
How to call made-up data?
What is Modern Vipassana?
When using the Proficiency Dice optional rule, how should they be used in determining a character's Spell Save DC?
In MTG, was there ever a five-color deck that worked well?
How to avoid a lengthy conversation with someone from the neighborhood I don't share interests with
Can't understand an ACT practice problem: Triangle appears to be isosceles, why isn't the answer 7.3~ here?
Export economy of Mars
How does shared_ptr<void> know which destructor to use?
Accurately recalling the key - can everyone do it?
Pronouns when writing from the point of view of a robot
Can I say "Gesundheit" if someone is coughing?
Does a bard know when a character uses their Bardic Inspiration?
How does Rust's 128-bit integer `i128` work on a 64-bit system?
How was the cosmonaut of the Soviet moon mission supposed to get back in the return vehicle?
Is law enforcement responsible for damages made by a search warrant?
What does "autolyco-sentimental" mean?
Representation of the concatenation at the type level
Is an "are" omitted in this sentence
A wiild aanimal, a cardinal direction, or a place by the water
What is the reason behind water not falling from a bucket at the top of loop?
How to match negative lookbehind with unknown characters between?
How do you access the matched groups in a JavaScript regular expression?Javascript: negative lookbehind equivalent?How to get first character of string?Regex Match all characters between two stringsHow to match “anything up until this sequence of characters” in a regular expression?Negative Lookbehind: Match a substring that's not preceded one of a set of charactersNegative lookbehind regex (PERL) with variable characters in-betweenignore preceding spaces using negative lookbehindNegative Lookbehind not negating entire matchHow to match a regex pattern with negative lookbehind on JavaScript?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I need to match all .get('asfd')
, but only in the case where .wait(.*)
doesn't exist beforehand.
.wait(500).get('asdf') // shouldn't match
.asdf('asdf').get('asdf') // should match
Unfortunately, negative look-behinds don't support quantifiers, so I'm not sure how to describe the void between .wait(
and ).get('asdf')
for d*
What's the approach for matching this unquantifiable area?
I figure I need some way to describe that there wasn't a wait
behind the last set of parenthesis, but is there a simple way to do that?
Thanks
javascript regex cypress negative-lookbehind
add a comment |
I need to match all .get('asfd')
, but only in the case where .wait(.*)
doesn't exist beforehand.
.wait(500).get('asdf') // shouldn't match
.asdf('asdf').get('asdf') // should match
Unfortunately, negative look-behinds don't support quantifiers, so I'm not sure how to describe the void between .wait(
and ).get('asdf')
for d*
What's the approach for matching this unquantifiable area?
I figure I need some way to describe that there wasn't a wait
behind the last set of parenthesis, but is there a simple way to do that?
Thanks
javascript regex cypress negative-lookbehind
add a comment |
I need to match all .get('asfd')
, but only in the case where .wait(.*)
doesn't exist beforehand.
.wait(500).get('asdf') // shouldn't match
.asdf('asdf').get('asdf') // should match
Unfortunately, negative look-behinds don't support quantifiers, so I'm not sure how to describe the void between .wait(
and ).get('asdf')
for d*
What's the approach for matching this unquantifiable area?
I figure I need some way to describe that there wasn't a wait
behind the last set of parenthesis, but is there a simple way to do that?
Thanks
javascript regex cypress negative-lookbehind
I need to match all .get('asfd')
, but only in the case where .wait(.*)
doesn't exist beforehand.
.wait(500).get('asdf') // shouldn't match
.asdf('asdf').get('asdf') // should match
Unfortunately, negative look-behinds don't support quantifiers, so I'm not sure how to describe the void between .wait(
and ).get('asdf')
for d*
What's the approach for matching this unquantifiable area?
I figure I need some way to describe that there wasn't a wait
behind the last set of parenthesis, but is there a simple way to do that?
Thanks
javascript regex cypress negative-lookbehind
javascript regex cypress negative-lookbehind
edited Mar 27 at 5:03
neaumusic
asked Mar 27 at 1:42
neaumusicneaumusic
5,4952 gold badges31 silver badges50 bronze badges
5,4952 gold badges31 silver badges50 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Ok, it took quite a lot of experimenting, and asking this question helped to clarify the situation.
The answer is to describe the in-between: separate from the look-behind.
(?<!wait)
(?:([^)]*))
(.get(.*))
That second section allows any character until a parenthesis. Sometimes, the first parenthesis appears inside quotes, and should be ignored. Not accounting for escaped quotes, my entire regex became:
((?<!wait)(.*)s*)(.get((?:"[^"]*"|'[^']*')[^)]*))
And I use it to insert .wait()
before/after .get()
with match groups 1 ($1
) and 2 ($2
)
$1.wait(234)$2.wait(234)
Wouldn't it be.*(?<!wait)(?:(.*))(.get(.*))
?
– JBis
Mar 27 at 2:11
add a comment |
I am not a regex expert, but how about this?
/^(?!.wait(d+)).*.get(.*)/g
Explanation:
(?!
Negative lookahead. Specifies a group
that can not match after the main expression (if it matches, the result is discarded).
.
Escaped character. Matches a "." character (char code
46).
w
Character. Matches a "w" character (char code 119).
Case sensitive.
a
Character. Matches a "a" character (char code 97).
Case sensitive.
i
Character. Matches a "i" character (char code 105).
Case sensitive.
t
Character. Matches a "t" character (char code 116).
Case sensitive.
(
Escaped character. Matches a "(" character (char code
40).
d
Digit. Matches any digit character (0-9).
+
Quantifier. Match 1 or more of the preceding
token.
)
Escaped character. Matches a ")" character (char code
41).
.
Dot. Matches any character except line breaks.
*
Quantifier. Match 0 or more of the preceding
token.
.
Escaped character. Matches a "." character (char code
46).
g
Character. Matches a "g" character (char code 103). Case
sensitive.
e
Character. Matches a "e" character (char code 101). Case
sensitive.
t
Character. Matches a "t" character (char code 116). Case
sensitive.
(
Escaped character. Matches a "(" character (char code
40).
.
Dot. Matches any character except line breaks.
*
Quantifier. Match 0 or more of the preceding
token.
)
Escaped character. Matches a ")" character (char code
41).
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%2f55368567%2fhow-to-match-negative-lookbehind-with-unknown-characters-between%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
Ok, it took quite a lot of experimenting, and asking this question helped to clarify the situation.
The answer is to describe the in-between: separate from the look-behind.
(?<!wait)
(?:([^)]*))
(.get(.*))
That second section allows any character until a parenthesis. Sometimes, the first parenthesis appears inside quotes, and should be ignored. Not accounting for escaped quotes, my entire regex became:
((?<!wait)(.*)s*)(.get((?:"[^"]*"|'[^']*')[^)]*))
And I use it to insert .wait()
before/after .get()
with match groups 1 ($1
) and 2 ($2
)
$1.wait(234)$2.wait(234)
Wouldn't it be.*(?<!wait)(?:(.*))(.get(.*))
?
– JBis
Mar 27 at 2:11
add a comment |
Ok, it took quite a lot of experimenting, and asking this question helped to clarify the situation.
The answer is to describe the in-between: separate from the look-behind.
(?<!wait)
(?:([^)]*))
(.get(.*))
That second section allows any character until a parenthesis. Sometimes, the first parenthesis appears inside quotes, and should be ignored. Not accounting for escaped quotes, my entire regex became:
((?<!wait)(.*)s*)(.get((?:"[^"]*"|'[^']*')[^)]*))
And I use it to insert .wait()
before/after .get()
with match groups 1 ($1
) and 2 ($2
)
$1.wait(234)$2.wait(234)
Wouldn't it be.*(?<!wait)(?:(.*))(.get(.*))
?
– JBis
Mar 27 at 2:11
add a comment |
Ok, it took quite a lot of experimenting, and asking this question helped to clarify the situation.
The answer is to describe the in-between: separate from the look-behind.
(?<!wait)
(?:([^)]*))
(.get(.*))
That second section allows any character until a parenthesis. Sometimes, the first parenthesis appears inside quotes, and should be ignored. Not accounting for escaped quotes, my entire regex became:
((?<!wait)(.*)s*)(.get((?:"[^"]*"|'[^']*')[^)]*))
And I use it to insert .wait()
before/after .get()
with match groups 1 ($1
) and 2 ($2
)
$1.wait(234)$2.wait(234)
Ok, it took quite a lot of experimenting, and asking this question helped to clarify the situation.
The answer is to describe the in-between: separate from the look-behind.
(?<!wait)
(?:([^)]*))
(.get(.*))
That second section allows any character until a parenthesis. Sometimes, the first parenthesis appears inside quotes, and should be ignored. Not accounting for escaped quotes, my entire regex became:
((?<!wait)(.*)s*)(.get((?:"[^"]*"|'[^']*')[^)]*))
And I use it to insert .wait()
before/after .get()
with match groups 1 ($1
) and 2 ($2
)
$1.wait(234)$2.wait(234)
edited Mar 27 at 5:06
answered Mar 27 at 1:55
neaumusicneaumusic
5,4952 gold badges31 silver badges50 bronze badges
5,4952 gold badges31 silver badges50 bronze badges
Wouldn't it be.*(?<!wait)(?:(.*))(.get(.*))
?
– JBis
Mar 27 at 2:11
add a comment |
Wouldn't it be.*(?<!wait)(?:(.*))(.get(.*))
?
– JBis
Mar 27 at 2:11
Wouldn't it be
.*(?<!wait)(?:(.*))(.get(.*))
?– JBis
Mar 27 at 2:11
Wouldn't it be
.*(?<!wait)(?:(.*))(.get(.*))
?– JBis
Mar 27 at 2:11
add a comment |
I am not a regex expert, but how about this?
/^(?!.wait(d+)).*.get(.*)/g
Explanation:
(?!
Negative lookahead. Specifies a group
that can not match after the main expression (if it matches, the result is discarded).
.
Escaped character. Matches a "." character (char code
46).
w
Character. Matches a "w" character (char code 119).
Case sensitive.
a
Character. Matches a "a" character (char code 97).
Case sensitive.
i
Character. Matches a "i" character (char code 105).
Case sensitive.
t
Character. Matches a "t" character (char code 116).
Case sensitive.
(
Escaped character. Matches a "(" character (char code
40).
d
Digit. Matches any digit character (0-9).
+
Quantifier. Match 1 or more of the preceding
token.
)
Escaped character. Matches a ")" character (char code
41).
.
Dot. Matches any character except line breaks.
*
Quantifier. Match 0 or more of the preceding
token.
.
Escaped character. Matches a "." character (char code
46).
g
Character. Matches a "g" character (char code 103). Case
sensitive.
e
Character. Matches a "e" character (char code 101). Case
sensitive.
t
Character. Matches a "t" character (char code 116). Case
sensitive.
(
Escaped character. Matches a "(" character (char code
40).
.
Dot. Matches any character except line breaks.
*
Quantifier. Match 0 or more of the preceding
token.
)
Escaped character. Matches a ")" character (char code
41).
add a comment |
I am not a regex expert, but how about this?
/^(?!.wait(d+)).*.get(.*)/g
Explanation:
(?!
Negative lookahead. Specifies a group
that can not match after the main expression (if it matches, the result is discarded).
.
Escaped character. Matches a "." character (char code
46).
w
Character. Matches a "w" character (char code 119).
Case sensitive.
a
Character. Matches a "a" character (char code 97).
Case sensitive.
i
Character. Matches a "i" character (char code 105).
Case sensitive.
t
Character. Matches a "t" character (char code 116).
Case sensitive.
(
Escaped character. Matches a "(" character (char code
40).
d
Digit. Matches any digit character (0-9).
+
Quantifier. Match 1 or more of the preceding
token.
)
Escaped character. Matches a ")" character (char code
41).
.
Dot. Matches any character except line breaks.
*
Quantifier. Match 0 or more of the preceding
token.
.
Escaped character. Matches a "." character (char code
46).
g
Character. Matches a "g" character (char code 103). Case
sensitive.
e
Character. Matches a "e" character (char code 101). Case
sensitive.
t
Character. Matches a "t" character (char code 116). Case
sensitive.
(
Escaped character. Matches a "(" character (char code
40).
.
Dot. Matches any character except line breaks.
*
Quantifier. Match 0 or more of the preceding
token.
)
Escaped character. Matches a ")" character (char code
41).
add a comment |
I am not a regex expert, but how about this?
/^(?!.wait(d+)).*.get(.*)/g
Explanation:
(?!
Negative lookahead. Specifies a group
that can not match after the main expression (if it matches, the result is discarded).
.
Escaped character. Matches a "." character (char code
46).
w
Character. Matches a "w" character (char code 119).
Case sensitive.
a
Character. Matches a "a" character (char code 97).
Case sensitive.
i
Character. Matches a "i" character (char code 105).
Case sensitive.
t
Character. Matches a "t" character (char code 116).
Case sensitive.
(
Escaped character. Matches a "(" character (char code
40).
d
Digit. Matches any digit character (0-9).
+
Quantifier. Match 1 or more of the preceding
token.
)
Escaped character. Matches a ")" character (char code
41).
.
Dot. Matches any character except line breaks.
*
Quantifier. Match 0 or more of the preceding
token.
.
Escaped character. Matches a "." character (char code
46).
g
Character. Matches a "g" character (char code 103). Case
sensitive.
e
Character. Matches a "e" character (char code 101). Case
sensitive.
t
Character. Matches a "t" character (char code 116). Case
sensitive.
(
Escaped character. Matches a "(" character (char code
40).
.
Dot. Matches any character except line breaks.
*
Quantifier. Match 0 or more of the preceding
token.
)
Escaped character. Matches a ")" character (char code
41).
I am not a regex expert, but how about this?
/^(?!.wait(d+)).*.get(.*)/g
Explanation:
(?!
Negative lookahead. Specifies a group
that can not match after the main expression (if it matches, the result is discarded).
.
Escaped character. Matches a "." character (char code
46).
w
Character. Matches a "w" character (char code 119).
Case sensitive.
a
Character. Matches a "a" character (char code 97).
Case sensitive.
i
Character. Matches a "i" character (char code 105).
Case sensitive.
t
Character. Matches a "t" character (char code 116).
Case sensitive.
(
Escaped character. Matches a "(" character (char code
40).
d
Digit. Matches any digit character (0-9).
+
Quantifier. Match 1 or more of the preceding
token.
)
Escaped character. Matches a ")" character (char code
41).
.
Dot. Matches any character except line breaks.
*
Quantifier. Match 0 or more of the preceding
token.
.
Escaped character. Matches a "." character (char code
46).
g
Character. Matches a "g" character (char code 103). Case
sensitive.
e
Character. Matches a "e" character (char code 101). Case
sensitive.
t
Character. Matches a "t" character (char code 116). Case
sensitive.
(
Escaped character. Matches a "(" character (char code
40).
.
Dot. Matches any character except line breaks.
*
Quantifier. Match 0 or more of the preceding
token.
)
Escaped character. Matches a ")" character (char code
41).
edited Mar 27 at 2:13
answered Mar 27 at 2:07
Ali ElkhateebAli Elkhateeb
6403 silver badges13 bronze badges
6403 silver badges13 bronze badges
add a comment |
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%2f55368567%2fhow-to-match-negative-lookbehind-with-unknown-characters-between%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