Parse line to get N values











up vote
0
down vote

favorite












I need help to get the N dates that could be in this line:




"vmsnapshot":"Snapshot 1 created on dom ago 5 11:03:09 -04 2018.
Info: OFF Snapshot solicitado según INC000001850649. Snapshot 2
created on dom ago 26 02:44:44 -03 2018. Info: OFF
user-VCD-snapshot-ab221cb8-539d-456a-8732-8500ec7fefa6-. "




I just need to rescue the dates, I have some ideas like adding it to an arrangement, but maybe there is something more optimal to do it.



Example result :
- ago 5 2018
- ago 26 2018



Thank you










share|improve this question
























  • Be clear. Are you asking to extract the dates from data represented as a string? What have you tried? Asking for a solution to even simple things is generally not going to get you much traction here. Hint: a naive approach is regular expressions: regex101.com
    – jdv
    Nov 7 at 15:16










  • @Manuel welcome to SO! What programming language do you use?
    – Ivan Zaruba
    Nov 7 at 15:38















up vote
0
down vote

favorite












I need help to get the N dates that could be in this line:




"vmsnapshot":"Snapshot 1 created on dom ago 5 11:03:09 -04 2018.
Info: OFF Snapshot solicitado según INC000001850649. Snapshot 2
created on dom ago 26 02:44:44 -03 2018. Info: OFF
user-VCD-snapshot-ab221cb8-539d-456a-8732-8500ec7fefa6-. "




I just need to rescue the dates, I have some ideas like adding it to an arrangement, but maybe there is something more optimal to do it.



Example result :
- ago 5 2018
- ago 26 2018



Thank you










share|improve this question
























  • Be clear. Are you asking to extract the dates from data represented as a string? What have you tried? Asking for a solution to even simple things is generally not going to get you much traction here. Hint: a naive approach is regular expressions: regex101.com
    – jdv
    Nov 7 at 15:16










  • @Manuel welcome to SO! What programming language do you use?
    – Ivan Zaruba
    Nov 7 at 15:38













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I need help to get the N dates that could be in this line:




"vmsnapshot":"Snapshot 1 created on dom ago 5 11:03:09 -04 2018.
Info: OFF Snapshot solicitado según INC000001850649. Snapshot 2
created on dom ago 26 02:44:44 -03 2018. Info: OFF
user-VCD-snapshot-ab221cb8-539d-456a-8732-8500ec7fefa6-. "




I just need to rescue the dates, I have some ideas like adding it to an arrangement, but maybe there is something more optimal to do it.



Example result :
- ago 5 2018
- ago 26 2018



Thank you










share|improve this question















I need help to get the N dates that could be in this line:




"vmsnapshot":"Snapshot 1 created on dom ago 5 11:03:09 -04 2018.
Info: OFF Snapshot solicitado según INC000001850649. Snapshot 2
created on dom ago 26 02:44:44 -03 2018. Info: OFF
user-VCD-snapshot-ab221cb8-539d-456a-8732-8500ec7fefa6-. "




I just need to rescue the dates, I have some ideas like adding it to an arrangement, but maybe there is something more optimal to do it.



Example result :
- ago 5 2018
- ago 26 2018



Thank you







javascript arrays parsing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 7 at 15:25









Luca Kiebel

7,30641431




7,30641431










asked Nov 7 at 15:02









Manuel

1




1












  • Be clear. Are you asking to extract the dates from data represented as a string? What have you tried? Asking for a solution to even simple things is generally not going to get you much traction here. Hint: a naive approach is regular expressions: regex101.com
    – jdv
    Nov 7 at 15:16










  • @Manuel welcome to SO! What programming language do you use?
    – Ivan Zaruba
    Nov 7 at 15:38


















  • Be clear. Are you asking to extract the dates from data represented as a string? What have you tried? Asking for a solution to even simple things is generally not going to get you much traction here. Hint: a naive approach is regular expressions: regex101.com
    – jdv
    Nov 7 at 15:16










  • @Manuel welcome to SO! What programming language do you use?
    – Ivan Zaruba
    Nov 7 at 15:38
















Be clear. Are you asking to extract the dates from data represented as a string? What have you tried? Asking for a solution to even simple things is generally not going to get you much traction here. Hint: a naive approach is regular expressions: regex101.com
– jdv
Nov 7 at 15:16




Be clear. Are you asking to extract the dates from data represented as a string? What have you tried? Asking for a solution to even simple things is generally not going to get you much traction here. Hint: a naive approach is regular expressions: regex101.com
– jdv
Nov 7 at 15:16












@Manuel welcome to SO! What programming language do you use?
– Ivan Zaruba
Nov 7 at 15:38




@Manuel welcome to SO! What programming language do you use?
– Ivan Zaruba
Nov 7 at 15:38












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Consider using regular expressions as it is usually the best approach for that kind of tasks.



In your case it will be something like this (JavaScript example)



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



Group 1 will capture ago <1 or more digits>



Group 2 will capture <space><any four digits>



Combining result of those two groups will give you the expected output.






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',
    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%2f53192099%2fparse-line-to-get-n-values%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








    up vote
    0
    down vote













    Consider using regular expressions as it is usually the best approach for that kind of tasks.



    In your case it will be something like this (JavaScript example)



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



    Group 1 will capture ago <1 or more digits>



    Group 2 will capture <space><any four digits>



    Combining result of those two groups will give you the expected output.






    share|improve this answer

























      up vote
      0
      down vote













      Consider using regular expressions as it is usually the best approach for that kind of tasks.



      In your case it will be something like this (JavaScript example)



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



      Group 1 will capture ago <1 or more digits>



      Group 2 will capture <space><any four digits>



      Combining result of those two groups will give you the expected output.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Consider using regular expressions as it is usually the best approach for that kind of tasks.



        In your case it will be something like this (JavaScript example)



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



        Group 1 will capture ago <1 or more digits>



        Group 2 will capture <space><any four digits>



        Combining result of those two groups will give you the expected output.






        share|improve this answer












        Consider using regular expressions as it is usually the best approach for that kind of tasks.



        In your case it will be something like this (JavaScript example)



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



        Group 1 will capture ago <1 or more digits>



        Group 2 will capture <space><any four digits>



        Combining result of those two groups will give you the expected output.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 7 at 15:46









        Ivan Zaruba

        1,117721




        1,117721






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53192099%2fparse-line-to-get-n-values%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







            這個網誌中的熱門文章

            Academy of Television Arts & Sciences

            L'Équipe

            1995 France bombings