Regex Capture betwee 2 Strings/Value
i want to capture a value between 2 strings, i tried many regex but no way.
Source Code:
</li><li><a href="/Journal/Year/123">Journal Title 2002</a> | <a href="/Journal/Year/456">2004</a> | <a href="/Journal/Year/789">2005</a></ul></div>
Regex i Tried:
(<li><a href=".journal.year.d+">)(.*)(<a href=".journal.year.d+">)
(?<=<li><a href=".journal.year.d+">)(.*)(?=<a href=".journal.year.d+">)
Capture Output :
Journal Title 2002
or (if possible)
Journal Title 2002 2004 2005
i hope you will help me with this.
Thanks in advance.
html regex notepad++
add a comment |
i want to capture a value between 2 strings, i tried many regex but no way.
Source Code:
</li><li><a href="/Journal/Year/123">Journal Title 2002</a> | <a href="/Journal/Year/456">2004</a> | <a href="/Journal/Year/789">2005</a></ul></div>
Regex i Tried:
(<li><a href=".journal.year.d+">)(.*)(<a href=".journal.year.d+">)
(?<=<li><a href=".journal.year.d+">)(.*)(?=<a href=".journal.year.d+">)
Capture Output :
Journal Title 2002
or (if possible)
Journal Title 2002 2004 2005
i hope you will help me with this.
Thanks in advance.
html regex notepad++
The downvotes are probably happening because you are trying to parse HTML content using regex. While regex might be part of the solution, you should consider using an HTML/XML parser.
– Tim Biegeleisen
Nov 23 '18 at 10:59
1
Try removing all tags.
– Wiktor Stribiżew
Nov 23 '18 at 11:37
add a comment |
i want to capture a value between 2 strings, i tried many regex but no way.
Source Code:
</li><li><a href="/Journal/Year/123">Journal Title 2002</a> | <a href="/Journal/Year/456">2004</a> | <a href="/Journal/Year/789">2005</a></ul></div>
Regex i Tried:
(<li><a href=".journal.year.d+">)(.*)(<a href=".journal.year.d+">)
(?<=<li><a href=".journal.year.d+">)(.*)(?=<a href=".journal.year.d+">)
Capture Output :
Journal Title 2002
or (if possible)
Journal Title 2002 2004 2005
i hope you will help me with this.
Thanks in advance.
html regex notepad++
i want to capture a value between 2 strings, i tried many regex but no way.
Source Code:
</li><li><a href="/Journal/Year/123">Journal Title 2002</a> | <a href="/Journal/Year/456">2004</a> | <a href="/Journal/Year/789">2005</a></ul></div>
Regex i Tried:
(<li><a href=".journal.year.d+">)(.*)(<a href=".journal.year.d+">)
(?<=<li><a href=".journal.year.d+">)(.*)(?=<a href=".journal.year.d+">)
Capture Output :
Journal Title 2002
or (if possible)
Journal Title 2002 2004 2005
i hope you will help me with this.
Thanks in advance.
html regex notepad++
html regex notepad++
edited Nov 23 '18 at 10:56
Wiktor Stribiżew
310k16131206
310k16131206
asked Nov 23 '18 at 10:55
Vendetta KappiVendetta Kappi
6
6
The downvotes are probably happening because you are trying to parse HTML content using regex. While regex might be part of the solution, you should consider using an HTML/XML parser.
– Tim Biegeleisen
Nov 23 '18 at 10:59
1
Try removing all tags.
– Wiktor Stribiżew
Nov 23 '18 at 11:37
add a comment |
The downvotes are probably happening because you are trying to parse HTML content using regex. While regex might be part of the solution, you should consider using an HTML/XML parser.
– Tim Biegeleisen
Nov 23 '18 at 10:59
1
Try removing all tags.
– Wiktor Stribiżew
Nov 23 '18 at 11:37
The downvotes are probably happening because you are trying to parse HTML content using regex. While regex might be part of the solution, you should consider using an HTML/XML parser.
– Tim Biegeleisen
Nov 23 '18 at 10:59
The downvotes are probably happening because you are trying to parse HTML content using regex. While regex might be part of the solution, you should consider using an HTML/XML parser.
– Tim Biegeleisen
Nov 23 '18 at 10:59
1
1
Try removing all tags.
– Wiktor Stribiżew
Nov 23 '18 at 11:37
Try removing all tags.
– Wiktor Stribiżew
Nov 23 '18 at 11:37
add a comment |
2 Answers
2
active
oldest
votes
It is not recommended to use a RegEx to parse HTML.
Instead use DOM
var titles = ;
document.querySelectorAll("[href^='/Journal']").forEach(function(link) {
titles.push(link.textContent.trim())
});
console.log(titles.join(" "));
<ul><li><a href="/Journal/Year/123">Journal Title 2002</a> | <a href="/Journal/Year/456">2004</a> | <a href="/Journal/Year/789">2005</a></ul>
Thank you for your reply, i am using a program and parsing is only available sing LR strings, Json, Regex and CSS Selector
– Vendetta Kappi
Nov 23 '18 at 11:04
add a comment |
https://regex101.com/r/IVUmJf/1
>([^<|]+)<
This Regex should work for your purpose. It captures everything between >
and <
except if there is a |
.
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%2f53445341%2fregex-capture-betwee-2-strings-value%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
It is not recommended to use a RegEx to parse HTML.
Instead use DOM
var titles = ;
document.querySelectorAll("[href^='/Journal']").forEach(function(link) {
titles.push(link.textContent.trim())
});
console.log(titles.join(" "));
<ul><li><a href="/Journal/Year/123">Journal Title 2002</a> | <a href="/Journal/Year/456">2004</a> | <a href="/Journal/Year/789">2005</a></ul>
Thank you for your reply, i am using a program and parsing is only available sing LR strings, Json, Regex and CSS Selector
– Vendetta Kappi
Nov 23 '18 at 11:04
add a comment |
It is not recommended to use a RegEx to parse HTML.
Instead use DOM
var titles = ;
document.querySelectorAll("[href^='/Journal']").forEach(function(link) {
titles.push(link.textContent.trim())
});
console.log(titles.join(" "));
<ul><li><a href="/Journal/Year/123">Journal Title 2002</a> | <a href="/Journal/Year/456">2004</a> | <a href="/Journal/Year/789">2005</a></ul>
Thank you for your reply, i am using a program and parsing is only available sing LR strings, Json, Regex and CSS Selector
– Vendetta Kappi
Nov 23 '18 at 11:04
add a comment |
It is not recommended to use a RegEx to parse HTML.
Instead use DOM
var titles = ;
document.querySelectorAll("[href^='/Journal']").forEach(function(link) {
titles.push(link.textContent.trim())
});
console.log(titles.join(" "));
<ul><li><a href="/Journal/Year/123">Journal Title 2002</a> | <a href="/Journal/Year/456">2004</a> | <a href="/Journal/Year/789">2005</a></ul>
It is not recommended to use a RegEx to parse HTML.
Instead use DOM
var titles = ;
document.querySelectorAll("[href^='/Journal']").forEach(function(link) {
titles.push(link.textContent.trim())
});
console.log(titles.join(" "));
<ul><li><a href="/Journal/Year/123">Journal Title 2002</a> | <a href="/Journal/Year/456">2004</a> | <a href="/Journal/Year/789">2005</a></ul>
var titles = ;
document.querySelectorAll("[href^='/Journal']").forEach(function(link) {
titles.push(link.textContent.trim())
});
console.log(titles.join(" "));
<ul><li><a href="/Journal/Year/123">Journal Title 2002</a> | <a href="/Journal/Year/456">2004</a> | <a href="/Journal/Year/789">2005</a></ul>
var titles = ;
document.querySelectorAll("[href^='/Journal']").forEach(function(link) {
titles.push(link.textContent.trim())
});
console.log(titles.join(" "));
<ul><li><a href="/Journal/Year/123">Journal Title 2002</a> | <a href="/Journal/Year/456">2004</a> | <a href="/Journal/Year/789">2005</a></ul>
answered Nov 23 '18 at 11:01
mplungjanmplungjan
87.2k21122181
87.2k21122181
Thank you for your reply, i am using a program and parsing is only available sing LR strings, Json, Regex and CSS Selector
– Vendetta Kappi
Nov 23 '18 at 11:04
add a comment |
Thank you for your reply, i am using a program and parsing is only available sing LR strings, Json, Regex and CSS Selector
– Vendetta Kappi
Nov 23 '18 at 11:04
Thank you for your reply, i am using a program and parsing is only available sing LR strings, Json, Regex and CSS Selector
– Vendetta Kappi
Nov 23 '18 at 11:04
Thank you for your reply, i am using a program and parsing is only available sing LR strings, Json, Regex and CSS Selector
– Vendetta Kappi
Nov 23 '18 at 11:04
add a comment |
https://regex101.com/r/IVUmJf/1
>([^<|]+)<
This Regex should work for your purpose. It captures everything between >
and <
except if there is a |
.
add a comment |
https://regex101.com/r/IVUmJf/1
>([^<|]+)<
This Regex should work for your purpose. It captures everything between >
and <
except if there is a |
.
add a comment |
https://regex101.com/r/IVUmJf/1
>([^<|]+)<
This Regex should work for your purpose. It captures everything between >
and <
except if there is a |
.
https://regex101.com/r/IVUmJf/1
>([^<|]+)<
This Regex should work for your purpose. It captures everything between >
and <
except if there is a |
.
answered Nov 23 '18 at 11:36
Laurent MouchartLaurent Mouchart
195213
195213
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%2f53445341%2fregex-capture-betwee-2-strings-value%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
The downvotes are probably happening because you are trying to parse HTML content using regex. While regex might be part of the solution, you should consider using an HTML/XML parser.
– Tim Biegeleisen
Nov 23 '18 at 10:59
1
Try removing all tags.
– Wiktor Stribiżew
Nov 23 '18 at 11:37