Regex Capture betwee 2 Strings/Value












-1















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.










share|improve this question

























  • 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
















-1















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.










share|improve this question

























  • 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














-1












-1








-1








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.










share|improve this question
















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++






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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



















  • 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












2 Answers
2






active

oldest

votes


















0














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>








share|improve this answer
























  • 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



















0














https://regex101.com/r/IVUmJf/1



>([^<|]+)<


This Regex should work for your purpose. It captures everything between > and < except if there is a |.






share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    0














    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>








    share|improve this answer
























    • 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
















    0














    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>








    share|improve this answer
























    • 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














    0












    0








    0







    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>








    share|improve this answer













    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>






    share|improve this answer












    share|improve this answer



    share|improve this answer










    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



















    • 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













    0














    https://regex101.com/r/IVUmJf/1



    >([^<|]+)<


    This Regex should work for your purpose. It captures everything between > and < except if there is a |.






    share|improve this answer




























      0














      https://regex101.com/r/IVUmJf/1



      >([^<|]+)<


      This Regex should work for your purpose. It captures everything between > and < except if there is a |.






      share|improve this answer


























        0












        0








        0







        https://regex101.com/r/IVUmJf/1



        >([^<|]+)<


        This Regex should work for your purpose. It captures everything between > and < except if there is a |.






        share|improve this answer













        https://regex101.com/r/IVUmJf/1



        >([^<|]+)<


        This Regex should work for your purpose. It captures everything between > and < except if there is a |.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 '18 at 11:36









        Laurent MouchartLaurent Mouchart

        195213




        195213






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Berounka

            Sphinx de Gizeh

            Different font size/position of beamer's navigation symbols template's content depending on regular/plain...