Visual Studio Code: regex expression starts with but not ends with
Visual Studio Code uses ripgrep to search in files, which doesn't support look around and backreferences.
I want to build an expression which returns all the phrases which start with a given string and does not end with given string e.g:
Starts with "http://blah.com
" but not ends with ".htm
"
Matches:
http://blah.com/tmp
Doesn’t match:
http://blah.com/tmp.htm
blah.com/tmp.htm
regex visual-studio-code
add a comment |
Visual Studio Code uses ripgrep to search in files, which doesn't support look around and backreferences.
I want to build an expression which returns all the phrases which start with a given string and does not end with given string e.g:
Starts with "http://blah.com
" but not ends with ".htm
"
Matches:
http://blah.com/tmp
Doesn’t match:
http://blah.com/tmp.htm
blah.com/tmp.htm
regex visual-studio-code
I want to search in the whole solution not only in one file
– GoldenAge
Nov 19 '18 at 13:12
This question has nothing to do with rust itself.
– hellow
Nov 19 '18 at 13:22
add a comment |
Visual Studio Code uses ripgrep to search in files, which doesn't support look around and backreferences.
I want to build an expression which returns all the phrases which start with a given string and does not end with given string e.g:
Starts with "http://blah.com
" but not ends with ".htm
"
Matches:
http://blah.com/tmp
Doesn’t match:
http://blah.com/tmp.htm
blah.com/tmp.htm
regex visual-studio-code
Visual Studio Code uses ripgrep to search in files, which doesn't support look around and backreferences.
I want to build an expression which returns all the phrases which start with a given string and does not end with given string e.g:
Starts with "http://blah.com
" but not ends with ".htm
"
Matches:
http://blah.com/tmp
Doesn’t match:
http://blah.com/tmp.htm
blah.com/tmp.htm
regex visual-studio-code
regex visual-studio-code
edited Nov 19 '18 at 13:44
Mark
11k33249
11k33249
asked Nov 19 '18 at 13:06
GoldenAge
499220
499220
I want to search in the whole solution not only in one file
– GoldenAge
Nov 19 '18 at 13:12
This question has nothing to do with rust itself.
– hellow
Nov 19 '18 at 13:22
add a comment |
I want to search in the whole solution not only in one file
– GoldenAge
Nov 19 '18 at 13:12
This question has nothing to do with rust itself.
– hellow
Nov 19 '18 at 13:22
I want to search in the whole solution not only in one file
– GoldenAge
Nov 19 '18 at 13:12
I want to search in the whole solution not only in one file
– GoldenAge
Nov 19 '18 at 13:12
This question has nothing to do with rust itself.
– hellow
Nov 19 '18 at 13:22
This question has nothing to do with rust itself.
– hellow
Nov 19 '18 at 13:22
add a comment |
1 Answer
1
active
oldest
votes
In your settings (to enable lookahead) :
"search.usePCRE2": true
Your regex (using a negative lookahead):
blah.com(?!.*.htm$)
[Edit] Added the $
if you absolutely want to exclude matches that do not end with the .htm
, not just followed somewhere in the string by .htm
.
From the v1.29 release notes:
It is also now possible to use backreferences and lookahead assertions
in regex searches, by setting "search.usePCRE2": true. This configures
ripgrep to use the PCRE2 regex engine. While PCRE2 supports many other
features, we only support regex expressions that are still valid in
JavaScript, because open editors are still searched using the editor's
JavaScript-based search.
Positive and negative lookaheads and backreferences.
Also note that a previous solution for this has been deprecated:
// Deprecated. Consider "search.usePCRE2" for advanced regex feature support.
// This setting is deprecated and now falls back on "search.usePCRE2".
"search.useRipgrep": false
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%2f53375311%2fvisual-studio-code-regex-expression-starts-with-but-not-ends-with%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In your settings (to enable lookahead) :
"search.usePCRE2": true
Your regex (using a negative lookahead):
blah.com(?!.*.htm$)
[Edit] Added the $
if you absolutely want to exclude matches that do not end with the .htm
, not just followed somewhere in the string by .htm
.
From the v1.29 release notes:
It is also now possible to use backreferences and lookahead assertions
in regex searches, by setting "search.usePCRE2": true. This configures
ripgrep to use the PCRE2 regex engine. While PCRE2 supports many other
features, we only support regex expressions that are still valid in
JavaScript, because open editors are still searched using the editor's
JavaScript-based search.
Positive and negative lookaheads and backreferences.
Also note that a previous solution for this has been deprecated:
// Deprecated. Consider "search.usePCRE2" for advanced regex feature support.
// This setting is deprecated and now falls back on "search.usePCRE2".
"search.useRipgrep": false
add a comment |
In your settings (to enable lookahead) :
"search.usePCRE2": true
Your regex (using a negative lookahead):
blah.com(?!.*.htm$)
[Edit] Added the $
if you absolutely want to exclude matches that do not end with the .htm
, not just followed somewhere in the string by .htm
.
From the v1.29 release notes:
It is also now possible to use backreferences and lookahead assertions
in regex searches, by setting "search.usePCRE2": true. This configures
ripgrep to use the PCRE2 regex engine. While PCRE2 supports many other
features, we only support regex expressions that are still valid in
JavaScript, because open editors are still searched using the editor's
JavaScript-based search.
Positive and negative lookaheads and backreferences.
Also note that a previous solution for this has been deprecated:
// Deprecated. Consider "search.usePCRE2" for advanced regex feature support.
// This setting is deprecated and now falls back on "search.usePCRE2".
"search.useRipgrep": false
add a comment |
In your settings (to enable lookahead) :
"search.usePCRE2": true
Your regex (using a negative lookahead):
blah.com(?!.*.htm$)
[Edit] Added the $
if you absolutely want to exclude matches that do not end with the .htm
, not just followed somewhere in the string by .htm
.
From the v1.29 release notes:
It is also now possible to use backreferences and lookahead assertions
in regex searches, by setting "search.usePCRE2": true. This configures
ripgrep to use the PCRE2 regex engine. While PCRE2 supports many other
features, we only support regex expressions that are still valid in
JavaScript, because open editors are still searched using the editor's
JavaScript-based search.
Positive and negative lookaheads and backreferences.
Also note that a previous solution for this has been deprecated:
// Deprecated. Consider "search.usePCRE2" for advanced regex feature support.
// This setting is deprecated and now falls back on "search.usePCRE2".
"search.useRipgrep": false
In your settings (to enable lookahead) :
"search.usePCRE2": true
Your regex (using a negative lookahead):
blah.com(?!.*.htm$)
[Edit] Added the $
if you absolutely want to exclude matches that do not end with the .htm
, not just followed somewhere in the string by .htm
.
From the v1.29 release notes:
It is also now possible to use backreferences and lookahead assertions
in regex searches, by setting "search.usePCRE2": true. This configures
ripgrep to use the PCRE2 regex engine. While PCRE2 supports many other
features, we only support regex expressions that are still valid in
JavaScript, because open editors are still searched using the editor's
JavaScript-based search.
Positive and negative lookaheads and backreferences.
Also note that a previous solution for this has been deprecated:
// Deprecated. Consider "search.usePCRE2" for advanced regex feature support.
// This setting is deprecated and now falls back on "search.usePCRE2".
"search.useRipgrep": false
edited Nov 19 '18 at 15:03
answered Nov 19 '18 at 13:28
Mark
11k33249
11k33249
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53375311%2fvisual-studio-code-regex-expression-starts-with-but-not-ends-with%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
I want to search in the whole solution not only in one file
– GoldenAge
Nov 19 '18 at 13:12
This question has nothing to do with rust itself.
– hellow
Nov 19 '18 at 13:22