How to parse username, ID or whole part using Ruby Regex in this sentence?












2















I have a sentences like this:



Hello @[Pratha](user:1), did you see @[John](user:3)'s answer?



And what I want to is get @[Pratha](user:1) and @[John](user:3). Either their names and ids or just as texts as I quoted so that i can explode and parse name and id myself.



But there is an issue here. Names Pratha and John may include non-abc characters like ', ,, -, + , etc... But not and ()



What I tried so far:



c = ''
f = c.match(/(?:s|^)(?:@(?!(?:d+|w+?_|_w+?)(?:s([)|$)))(w+)(?=s|$)/i)


But no success.










share|improve this question























  • FWIW, that's an example of a library for your latest question, github.com/avivr/search-parser .

    – estus
    Dec 25 '18 at 19:00
















2















I have a sentences like this:



Hello @[Pratha](user:1), did you see @[John](user:3)'s answer?



And what I want to is get @[Pratha](user:1) and @[John](user:3). Either their names and ids or just as texts as I quoted so that i can explode and parse name and id myself.



But there is an issue here. Names Pratha and John may include non-abc characters like ', ,, -, + , etc... But not and ()



What I tried so far:



c = ''
f = c.match(/(?:s|^)(?:@(?!(?:d+|w+?_|_w+?)(?:s([)|$)))(w+)(?=s|$)/i)


But no success.










share|improve this question























  • FWIW, that's an example of a library for your latest question, github.com/avivr/search-parser .

    – estus
    Dec 25 '18 at 19:00














2












2








2








I have a sentences like this:



Hello @[Pratha](user:1), did you see @[John](user:3)'s answer?



And what I want to is get @[Pratha](user:1) and @[John](user:3). Either their names and ids or just as texts as I quoted so that i can explode and parse name and id myself.



But there is an issue here. Names Pratha and John may include non-abc characters like ', ,, -, + , etc... But not and ()



What I tried so far:



c = ''
f = c.match(/(?:s|^)(?:@(?!(?:d+|w+?_|_w+?)(?:s([)|$)))(w+)(?=s|$)/i)


But no success.










share|improve this question














I have a sentences like this:



Hello @[Pratha](user:1), did you see @[John](user:3)'s answer?



And what I want to is get @[Pratha](user:1) and @[John](user:3). Either their names and ids or just as texts as I quoted so that i can explode and parse name and id myself.



But there is an issue here. Names Pratha and John may include non-abc characters like ', ,, -, + , etc... But not and ()



What I tried so far:



c = ''
f = c.match(/(?:s|^)(?:@(?!(?:d+|w+?_|_w+?)(?:s([)|$)))(w+)(?=s|$)/i)


But no success.







ruby regex






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 13:40









PrathaPratha

1907




1907













  • FWIW, that's an example of a library for your latest question, github.com/avivr/search-parser .

    – estus
    Dec 25 '18 at 19:00



















  • FWIW, that's an example of a library for your latest question, github.com/avivr/search-parser .

    – estus
    Dec 25 '18 at 19:00

















FWIW, that's an example of a library for your latest question, github.com/avivr/search-parser .

– estus
Dec 25 '18 at 19:00





FWIW, that's an example of a library for your latest question, github.com/avivr/search-parser .

– estus
Dec 25 '18 at 19:00












3 Answers
3






active

oldest

votes


















3














You may use



/@[([^]*)]([^()]*:(d+))/


See the regex demo



Details





  • @ - a @ char


  • [ - a [


  • ([^]*) - Group 1: 0+ chars other than [ and ]


  • ] - a ] char


  • ( - a ( char


  • [^()]*- 0+ chars other than ( and )


  • : - a colon


  • (d+) - Group 2: 1 or more digits


  • ) - a ) char.


Sample Ruby code:



s = "Hello @[Pratha](user:1), did you see @[John](user:3)'s answer?"
rx = /@[([^]*)]([^()]*:(d+))/
res = s.scan(rx)
puts res
# = > [["Pratha", "1"], ["John", "3"]]





share|improve this answer


























  • I do not need user:. Just ID. Can we grab that only? And is there a specific difference between yours and @The fourth bird?

    – Pratha
    Nov 23 '18 at 14:00











  • I think you misunderstand me. I just need name and ID. Like below. So output should be Pratha => 1, John => 3

    – Pratha
    Nov 23 '18 at 14:03











  • BTW, I will probably drop B because message (which user writes) maybe doesn't have a space before @ For example: Hello@[Pratha](user:1) As you can see there is no space after Hello.

    – Pratha
    Nov 23 '18 at 14:05













  • @Pratha Ok, then (?:^|s) was a mistake in your pattern. I updated the code, regex and demos.

    – Wiktor Stribiżew
    Nov 23 '18 at 14:08













  • @CarySwoveland True, I updated the answer. I was playing with some Ruby code from another SO answer trying out various approaches and this block remained.

    – Wiktor Stribiżew
    Nov 23 '18 at 18:16



















1














"Hello @[Pratha](user:1), did you see @[John](user:3)'s answer?".scan(/@.*?)/)
#⇒ ["@[Pratha](user:1)", "@[John](user:3)"]


Since the line is not coming from the user input, you might rely on that the part you are interested in starts with @ and ends with ).






share|improve this answer































    1














    You could use 2 capturing groups to get the names and the id's:



    @[([^]]+)]([^:]+:([^)]+))



    That will match





    • @ Match literally


    • [ Match [


    • ([^]]+) 1st capturing group which matches not ] 1+ times using a negated character class.


    • ( Match literally


    • [^:]+: Match not :, then match :


    • ([^)]+) 2nd capturing group which matches not ) 1+ times


    • ) Match )


    Regex demo | Ruby demo






    share|improve this answer





















    • 1





      All answers are giving correct output, however, Wiktor's and yours parse user's separately. And your solution just parses ID which is perfect.

      – Pratha
      Nov 23 '18 at 13:54











    • Just a question, do we need B at start like Wiktor did? (to prevent start with a word)

      – Pratha
      Nov 23 '18 at 13:57











    • @Pratha I have explained what B does - it won't match @ if it is inside of a word. Also, see my code snippet.

      – Wiktor Stribiżew
      Nov 23 '18 at 14:00













    • It depends on what you would allow to match, B asserts the position where b does not match.

      – The fourth bird
      Nov 23 '18 at 14:01











    • @Pratha You could also use (?<!S)@[([^]*)](([^()]*)) Demo to make sure what is on the left if not a non whitespace character.

      – The fourth bird
      Nov 23 '18 at 14:06











    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%2f53447793%2fhow-to-parse-username-id-or-whole-part-using-ruby-regex-in-this-sentence%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    You may use



    /@[([^]*)]([^()]*:(d+))/


    See the regex demo



    Details





    • @ - a @ char


    • [ - a [


    • ([^]*) - Group 1: 0+ chars other than [ and ]


    • ] - a ] char


    • ( - a ( char


    • [^()]*- 0+ chars other than ( and )


    • : - a colon


    • (d+) - Group 2: 1 or more digits


    • ) - a ) char.


    Sample Ruby code:



    s = "Hello @[Pratha](user:1), did you see @[John](user:3)'s answer?"
    rx = /@[([^]*)]([^()]*:(d+))/
    res = s.scan(rx)
    puts res
    # = > [["Pratha", "1"], ["John", "3"]]





    share|improve this answer


























    • I do not need user:. Just ID. Can we grab that only? And is there a specific difference between yours and @The fourth bird?

      – Pratha
      Nov 23 '18 at 14:00











    • I think you misunderstand me. I just need name and ID. Like below. So output should be Pratha => 1, John => 3

      – Pratha
      Nov 23 '18 at 14:03











    • BTW, I will probably drop B because message (which user writes) maybe doesn't have a space before @ For example: Hello@[Pratha](user:1) As you can see there is no space after Hello.

      – Pratha
      Nov 23 '18 at 14:05













    • @Pratha Ok, then (?:^|s) was a mistake in your pattern. I updated the code, regex and demos.

      – Wiktor Stribiżew
      Nov 23 '18 at 14:08













    • @CarySwoveland True, I updated the answer. I was playing with some Ruby code from another SO answer trying out various approaches and this block remained.

      – Wiktor Stribiżew
      Nov 23 '18 at 18:16
















    3














    You may use



    /@[([^]*)]([^()]*:(d+))/


    See the regex demo



    Details





    • @ - a @ char


    • [ - a [


    • ([^]*) - Group 1: 0+ chars other than [ and ]


    • ] - a ] char


    • ( - a ( char


    • [^()]*- 0+ chars other than ( and )


    • : - a colon


    • (d+) - Group 2: 1 or more digits


    • ) - a ) char.


    Sample Ruby code:



    s = "Hello @[Pratha](user:1), did you see @[John](user:3)'s answer?"
    rx = /@[([^]*)]([^()]*:(d+))/
    res = s.scan(rx)
    puts res
    # = > [["Pratha", "1"], ["John", "3"]]





    share|improve this answer


























    • I do not need user:. Just ID. Can we grab that only? And is there a specific difference between yours and @The fourth bird?

      – Pratha
      Nov 23 '18 at 14:00











    • I think you misunderstand me. I just need name and ID. Like below. So output should be Pratha => 1, John => 3

      – Pratha
      Nov 23 '18 at 14:03











    • BTW, I will probably drop B because message (which user writes) maybe doesn't have a space before @ For example: Hello@[Pratha](user:1) As you can see there is no space after Hello.

      – Pratha
      Nov 23 '18 at 14:05













    • @Pratha Ok, then (?:^|s) was a mistake in your pattern. I updated the code, regex and demos.

      – Wiktor Stribiżew
      Nov 23 '18 at 14:08













    • @CarySwoveland True, I updated the answer. I was playing with some Ruby code from another SO answer trying out various approaches and this block remained.

      – Wiktor Stribiżew
      Nov 23 '18 at 18:16














    3












    3








    3







    You may use



    /@[([^]*)]([^()]*:(d+))/


    See the regex demo



    Details





    • @ - a @ char


    • [ - a [


    • ([^]*) - Group 1: 0+ chars other than [ and ]


    • ] - a ] char


    • ( - a ( char


    • [^()]*- 0+ chars other than ( and )


    • : - a colon


    • (d+) - Group 2: 1 or more digits


    • ) - a ) char.


    Sample Ruby code:



    s = "Hello @[Pratha](user:1), did you see @[John](user:3)'s answer?"
    rx = /@[([^]*)]([^()]*:(d+))/
    res = s.scan(rx)
    puts res
    # = > [["Pratha", "1"], ["John", "3"]]





    share|improve this answer















    You may use



    /@[([^]*)]([^()]*:(d+))/


    See the regex demo



    Details





    • @ - a @ char


    • [ - a [


    • ([^]*) - Group 1: 0+ chars other than [ and ]


    • ] - a ] char


    • ( - a ( char


    • [^()]*- 0+ chars other than ( and )


    • : - a colon


    • (d+) - Group 2: 1 or more digits


    • ) - a ) char.


    Sample Ruby code:



    s = "Hello @[Pratha](user:1), did you see @[John](user:3)'s answer?"
    rx = /@[([^]*)]([^()]*:(d+))/
    res = s.scan(rx)
    puts res
    # = > [["Pratha", "1"], ["John", "3"]]






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 23 '18 at 18:15

























    answered Nov 23 '18 at 13:48









    Wiktor StribiżewWiktor Stribiżew

    316k16134215




    316k16134215













    • I do not need user:. Just ID. Can we grab that only? And is there a specific difference between yours and @The fourth bird?

      – Pratha
      Nov 23 '18 at 14:00











    • I think you misunderstand me. I just need name and ID. Like below. So output should be Pratha => 1, John => 3

      – Pratha
      Nov 23 '18 at 14:03











    • BTW, I will probably drop B because message (which user writes) maybe doesn't have a space before @ For example: Hello@[Pratha](user:1) As you can see there is no space after Hello.

      – Pratha
      Nov 23 '18 at 14:05













    • @Pratha Ok, then (?:^|s) was a mistake in your pattern. I updated the code, regex and demos.

      – Wiktor Stribiżew
      Nov 23 '18 at 14:08













    • @CarySwoveland True, I updated the answer. I was playing with some Ruby code from another SO answer trying out various approaches and this block remained.

      – Wiktor Stribiżew
      Nov 23 '18 at 18:16



















    • I do not need user:. Just ID. Can we grab that only? And is there a specific difference between yours and @The fourth bird?

      – Pratha
      Nov 23 '18 at 14:00











    • I think you misunderstand me. I just need name and ID. Like below. So output should be Pratha => 1, John => 3

      – Pratha
      Nov 23 '18 at 14:03











    • BTW, I will probably drop B because message (which user writes) maybe doesn't have a space before @ For example: Hello@[Pratha](user:1) As you can see there is no space after Hello.

      – Pratha
      Nov 23 '18 at 14:05













    • @Pratha Ok, then (?:^|s) was a mistake in your pattern. I updated the code, regex and demos.

      – Wiktor Stribiżew
      Nov 23 '18 at 14:08













    • @CarySwoveland True, I updated the answer. I was playing with some Ruby code from another SO answer trying out various approaches and this block remained.

      – Wiktor Stribiżew
      Nov 23 '18 at 18:16

















    I do not need user:. Just ID. Can we grab that only? And is there a specific difference between yours and @The fourth bird?

    – Pratha
    Nov 23 '18 at 14:00





    I do not need user:. Just ID. Can we grab that only? And is there a specific difference between yours and @The fourth bird?

    – Pratha
    Nov 23 '18 at 14:00













    I think you misunderstand me. I just need name and ID. Like below. So output should be Pratha => 1, John => 3

    – Pratha
    Nov 23 '18 at 14:03





    I think you misunderstand me. I just need name and ID. Like below. So output should be Pratha => 1, John => 3

    – Pratha
    Nov 23 '18 at 14:03













    BTW, I will probably drop B because message (which user writes) maybe doesn't have a space before @ For example: Hello@[Pratha](user:1) As you can see there is no space after Hello.

    – Pratha
    Nov 23 '18 at 14:05







    BTW, I will probably drop B because message (which user writes) maybe doesn't have a space before @ For example: Hello@[Pratha](user:1) As you can see there is no space after Hello.

    – Pratha
    Nov 23 '18 at 14:05















    @Pratha Ok, then (?:^|s) was a mistake in your pattern. I updated the code, regex and demos.

    – Wiktor Stribiżew
    Nov 23 '18 at 14:08







    @Pratha Ok, then (?:^|s) was a mistake in your pattern. I updated the code, regex and demos.

    – Wiktor Stribiżew
    Nov 23 '18 at 14:08















    @CarySwoveland True, I updated the answer. I was playing with some Ruby code from another SO answer trying out various approaches and this block remained.

    – Wiktor Stribiżew
    Nov 23 '18 at 18:16





    @CarySwoveland True, I updated the answer. I was playing with some Ruby code from another SO answer trying out various approaches and this block remained.

    – Wiktor Stribiżew
    Nov 23 '18 at 18:16













    1














    "Hello @[Pratha](user:1), did you see @[John](user:3)'s answer?".scan(/@.*?)/)
    #⇒ ["@[Pratha](user:1)", "@[John](user:3)"]


    Since the line is not coming from the user input, you might rely on that the part you are interested in starts with @ and ends with ).






    share|improve this answer




























      1














      "Hello @[Pratha](user:1), did you see @[John](user:3)'s answer?".scan(/@.*?)/)
      #⇒ ["@[Pratha](user:1)", "@[John](user:3)"]


      Since the line is not coming from the user input, you might rely on that the part you are interested in starts with @ and ends with ).






      share|improve this answer


























        1












        1








        1







        "Hello @[Pratha](user:1), did you see @[John](user:3)'s answer?".scan(/@.*?)/)
        #⇒ ["@[Pratha](user:1)", "@[John](user:3)"]


        Since the line is not coming from the user input, you might rely on that the part you are interested in starts with @ and ends with ).






        share|improve this answer













        "Hello @[Pratha](user:1), did you see @[John](user:3)'s answer?".scan(/@.*?)/)
        #⇒ ["@[Pratha](user:1)", "@[John](user:3)"]


        Since the line is not coming from the user input, you might rely on that the part you are interested in starts with @ and ends with ).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 '18 at 13:42









        Aleksei MatiushkinAleksei Matiushkin

        81.8k95591




        81.8k95591























            1














            You could use 2 capturing groups to get the names and the id's:



            @[([^]]+)]([^:]+:([^)]+))



            That will match





            • @ Match literally


            • [ Match [


            • ([^]]+) 1st capturing group which matches not ] 1+ times using a negated character class.


            • ( Match literally


            • [^:]+: Match not :, then match :


            • ([^)]+) 2nd capturing group which matches not ) 1+ times


            • ) Match )


            Regex demo | Ruby demo






            share|improve this answer





















            • 1





              All answers are giving correct output, however, Wiktor's and yours parse user's separately. And your solution just parses ID which is perfect.

              – Pratha
              Nov 23 '18 at 13:54











            • Just a question, do we need B at start like Wiktor did? (to prevent start with a word)

              – Pratha
              Nov 23 '18 at 13:57











            • @Pratha I have explained what B does - it won't match @ if it is inside of a word. Also, see my code snippet.

              – Wiktor Stribiżew
              Nov 23 '18 at 14:00













            • It depends on what you would allow to match, B asserts the position where b does not match.

              – The fourth bird
              Nov 23 '18 at 14:01











            • @Pratha You could also use (?<!S)@[([^]*)](([^()]*)) Demo to make sure what is on the left if not a non whitespace character.

              – The fourth bird
              Nov 23 '18 at 14:06
















            1














            You could use 2 capturing groups to get the names and the id's:



            @[([^]]+)]([^:]+:([^)]+))



            That will match





            • @ Match literally


            • [ Match [


            • ([^]]+) 1st capturing group which matches not ] 1+ times using a negated character class.


            • ( Match literally


            • [^:]+: Match not :, then match :


            • ([^)]+) 2nd capturing group which matches not ) 1+ times


            • ) Match )


            Regex demo | Ruby demo






            share|improve this answer





















            • 1





              All answers are giving correct output, however, Wiktor's and yours parse user's separately. And your solution just parses ID which is perfect.

              – Pratha
              Nov 23 '18 at 13:54











            • Just a question, do we need B at start like Wiktor did? (to prevent start with a word)

              – Pratha
              Nov 23 '18 at 13:57











            • @Pratha I have explained what B does - it won't match @ if it is inside of a word. Also, see my code snippet.

              – Wiktor Stribiżew
              Nov 23 '18 at 14:00













            • It depends on what you would allow to match, B asserts the position where b does not match.

              – The fourth bird
              Nov 23 '18 at 14:01











            • @Pratha You could also use (?<!S)@[([^]*)](([^()]*)) Demo to make sure what is on the left if not a non whitespace character.

              – The fourth bird
              Nov 23 '18 at 14:06














            1












            1








            1







            You could use 2 capturing groups to get the names and the id's:



            @[([^]]+)]([^:]+:([^)]+))



            That will match





            • @ Match literally


            • [ Match [


            • ([^]]+) 1st capturing group which matches not ] 1+ times using a negated character class.


            • ( Match literally


            • [^:]+: Match not :, then match :


            • ([^)]+) 2nd capturing group which matches not ) 1+ times


            • ) Match )


            Regex demo | Ruby demo






            share|improve this answer















            You could use 2 capturing groups to get the names and the id's:



            @[([^]]+)]([^:]+:([^)]+))



            That will match





            • @ Match literally


            • [ Match [


            • ([^]]+) 1st capturing group which matches not ] 1+ times using a negated character class.


            • ( Match literally


            • [^:]+: Match not :, then match :


            • ([^)]+) 2nd capturing group which matches not ) 1+ times


            • ) Match )


            Regex demo | Ruby demo







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 23 '18 at 14:24

























            answered Nov 23 '18 at 13:46









            The fourth birdThe fourth bird

            23k81427




            23k81427








            • 1





              All answers are giving correct output, however, Wiktor's and yours parse user's separately. And your solution just parses ID which is perfect.

              – Pratha
              Nov 23 '18 at 13:54











            • Just a question, do we need B at start like Wiktor did? (to prevent start with a word)

              – Pratha
              Nov 23 '18 at 13:57











            • @Pratha I have explained what B does - it won't match @ if it is inside of a word. Also, see my code snippet.

              – Wiktor Stribiżew
              Nov 23 '18 at 14:00













            • It depends on what you would allow to match, B asserts the position where b does not match.

              – The fourth bird
              Nov 23 '18 at 14:01











            • @Pratha You could also use (?<!S)@[([^]*)](([^()]*)) Demo to make sure what is on the left if not a non whitespace character.

              – The fourth bird
              Nov 23 '18 at 14:06














            • 1





              All answers are giving correct output, however, Wiktor's and yours parse user's separately. And your solution just parses ID which is perfect.

              – Pratha
              Nov 23 '18 at 13:54











            • Just a question, do we need B at start like Wiktor did? (to prevent start with a word)

              – Pratha
              Nov 23 '18 at 13:57











            • @Pratha I have explained what B does - it won't match @ if it is inside of a word. Also, see my code snippet.

              – Wiktor Stribiżew
              Nov 23 '18 at 14:00













            • It depends on what you would allow to match, B asserts the position where b does not match.

              – The fourth bird
              Nov 23 '18 at 14:01











            • @Pratha You could also use (?<!S)@[([^]*)](([^()]*)) Demo to make sure what is on the left if not a non whitespace character.

              – The fourth bird
              Nov 23 '18 at 14:06








            1




            1





            All answers are giving correct output, however, Wiktor's and yours parse user's separately. And your solution just parses ID which is perfect.

            – Pratha
            Nov 23 '18 at 13:54





            All answers are giving correct output, however, Wiktor's and yours parse user's separately. And your solution just parses ID which is perfect.

            – Pratha
            Nov 23 '18 at 13:54













            Just a question, do we need B at start like Wiktor did? (to prevent start with a word)

            – Pratha
            Nov 23 '18 at 13:57





            Just a question, do we need B at start like Wiktor did? (to prevent start with a word)

            – Pratha
            Nov 23 '18 at 13:57













            @Pratha I have explained what B does - it won't match @ if it is inside of a word. Also, see my code snippet.

            – Wiktor Stribiżew
            Nov 23 '18 at 14:00







            @Pratha I have explained what B does - it won't match @ if it is inside of a word. Also, see my code snippet.

            – Wiktor Stribiżew
            Nov 23 '18 at 14:00















            It depends on what you would allow to match, B asserts the position where b does not match.

            – The fourth bird
            Nov 23 '18 at 14:01





            It depends on what you would allow to match, B asserts the position where b does not match.

            – The fourth bird
            Nov 23 '18 at 14:01













            @Pratha You could also use (?<!S)@[([^]*)](([^()]*)) Demo to make sure what is on the left if not a non whitespace character.

            – The fourth bird
            Nov 23 '18 at 14:06





            @Pratha You could also use (?<!S)@[([^]*)](([^()]*)) Demo to make sure what is on the left if not a non whitespace character.

            – The fourth bird
            Nov 23 '18 at 14:06


















            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%2f53447793%2fhow-to-parse-username-id-or-whole-part-using-ruby-regex-in-this-sentence%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

            Wiesbaden

            Marschland

            Dieringhausen