Using regular expressions via `re-search-forward` in elisp [duplicate]

Multi tool use
Multi tool use












0
















This question already has an answer here:




  • Emacs - regular expressions in Lisp need to be double-escaped - why?

    4 answers




I want to search for an regular expression with the function re-search-forward



When I tried using the examples from the page
here: https://www.emacswiki.org/emacs/RegularExpression#toc1



specifically the regular expression w{20,} used to search for a word with 20 letters or more, I get an error.



Here I am placing my cursor after the closing parenthesis in my Lisp buffer and pressing C-x C-e for evaluating it.



However, when I use the Regexp I-search via,
C-M-s it highlights the correct word as expected.



Why is this?



enter image description hereenter image description here










share|improve this question













marked as duplicate by phils elisp
Users with the  elisp badge can single-handedly close elisp questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 18 '18 at 5:35


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




















    0
















    This question already has an answer here:




    • Emacs - regular expressions in Lisp need to be double-escaped - why?

      4 answers




    I want to search for an regular expression with the function re-search-forward



    When I tried using the examples from the page
    here: https://www.emacswiki.org/emacs/RegularExpression#toc1



    specifically the regular expression w{20,} used to search for a word with 20 letters or more, I get an error.



    Here I am placing my cursor after the closing parenthesis in my Lisp buffer and pressing C-x C-e for evaluating it.



    However, when I use the Regexp I-search via,
    C-M-s it highlights the correct word as expected.



    Why is this?



    enter image description hereenter image description here










    share|improve this question













    marked as duplicate by phils elisp
    Users with the  elisp badge can single-handedly close elisp questions as duplicates and reopen them as needed.

    StackExchange.ready(function() {
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function() {
    $hover.showInfoMessage('', {
    messageElement: $msg.clone().show(),
    transient: false,
    position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
    dismissable: false,
    relativeToBody: true
    });
    },
    function() {
    StackExchange.helpers.removeMessages();
    }
    );
    });
    });
    Nov 18 '18 at 5:35


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















      0












      0








      0









      This question already has an answer here:




      • Emacs - regular expressions in Lisp need to be double-escaped - why?

        4 answers




      I want to search for an regular expression with the function re-search-forward



      When I tried using the examples from the page
      here: https://www.emacswiki.org/emacs/RegularExpression#toc1



      specifically the regular expression w{20,} used to search for a word with 20 letters or more, I get an error.



      Here I am placing my cursor after the closing parenthesis in my Lisp buffer and pressing C-x C-e for evaluating it.



      However, when I use the Regexp I-search via,
      C-M-s it highlights the correct word as expected.



      Why is this?



      enter image description hereenter image description here










      share|improve this question















      This question already has an answer here:




      • Emacs - regular expressions in Lisp need to be double-escaped - why?

        4 answers




      I want to search for an regular expression with the function re-search-forward



      When I tried using the examples from the page
      here: https://www.emacswiki.org/emacs/RegularExpression#toc1



      specifically the regular expression w{20,} used to search for a word with 20 letters or more, I get an error.



      Here I am placing my cursor after the closing parenthesis in my Lisp buffer and pressing C-x C-e for evaluating it.



      However, when I use the Regexp I-search via,
      C-M-s it highlights the correct word as expected.



      Why is this?



      enter image description hereenter image description here





      This question already has an answer here:




      • Emacs - regular expressions in Lisp need to be double-escaped - why?

        4 answers








      elisp






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 18 '18 at 2:51









      smilingbuddhasmilingbuddha

      5,5072184142




      5,5072184142




      marked as duplicate by phils elisp
      Users with the  elisp badge can single-handedly close elisp questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 18 '18 at 5:35


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by phils elisp
      Users with the  elisp badge can single-handedly close elisp questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 18 '18 at 5:35


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


























          1 Answer
          1






          active

          oldest

          votes


















          3














          This regexp:



          w{20,}


          is expressed in a double-quoted elisp string like so:



          "\w\{20,\}"


          Backslashes are special to the double-quoted read syntax for strings as well as being special to regexp syntax; so if a backslash is for the regexp, you need to double it.






          share|improve this answer
























          • Notice also how, in the screenshots in the question, the incorrect singular backslashes are coloured red? That is Emacs (26+) telling you that they are probably a mistake.

            – phils
            Nov 23 '18 at 22:29


















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          This regexp:



          w{20,}


          is expressed in a double-quoted elisp string like so:



          "\w\{20,\}"


          Backslashes are special to the double-quoted read syntax for strings as well as being special to regexp syntax; so if a backslash is for the regexp, you need to double it.






          share|improve this answer
























          • Notice also how, in the screenshots in the question, the incorrect singular backslashes are coloured red? That is Emacs (26+) telling you that they are probably a mistake.

            – phils
            Nov 23 '18 at 22:29
















          3














          This regexp:



          w{20,}


          is expressed in a double-quoted elisp string like so:



          "\w\{20,\}"


          Backslashes are special to the double-quoted read syntax for strings as well as being special to regexp syntax; so if a backslash is for the regexp, you need to double it.






          share|improve this answer
























          • Notice also how, in the screenshots in the question, the incorrect singular backslashes are coloured red? That is Emacs (26+) telling you that they are probably a mistake.

            – phils
            Nov 23 '18 at 22:29














          3












          3








          3







          This regexp:



          w{20,}


          is expressed in a double-quoted elisp string like so:



          "\w\{20,\}"


          Backslashes are special to the double-quoted read syntax for strings as well as being special to regexp syntax; so if a backslash is for the regexp, you need to double it.






          share|improve this answer













          This regexp:



          w{20,}


          is expressed in a double-quoted elisp string like so:



          "\w\{20,\}"


          Backslashes are special to the double-quoted read syntax for strings as well as being special to regexp syntax; so if a backslash is for the regexp, you need to double it.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 18 '18 at 5:33









          philsphils

          57.8k7109142




          57.8k7109142













          • Notice also how, in the screenshots in the question, the incorrect singular backslashes are coloured red? That is Emacs (26+) telling you that they are probably a mistake.

            – phils
            Nov 23 '18 at 22:29



















          • Notice also how, in the screenshots in the question, the incorrect singular backslashes are coloured red? That is Emacs (26+) telling you that they are probably a mistake.

            – phils
            Nov 23 '18 at 22:29

















          Notice also how, in the screenshots in the question, the incorrect singular backslashes are coloured red? That is Emacs (26+) telling you that they are probably a mistake.

          – phils
          Nov 23 '18 at 22:29





          Notice also how, in the screenshots in the question, the incorrect singular backslashes are coloured red? That is Emacs (26+) telling you that they are probably a mistake.

          – phils
          Nov 23 '18 at 22:29



          H6t8RyKTtN9FMISCpWNGOfTVWzYY,YIWeckwBFBbHJbAsnXCg3W,rFZjW1 q1YV,0B,Al6aoAG,pGHl91Xx
          mG,JXseIhba,OsC uwwdAb 88Gi XS8ingkP Ujz P,nZeZn,oL,ijk4t8aqjSw5jRh9S5Up5QOW,s w7ZAiE KT3Hj wJkYQubR8UTNudw

          Popular posts from this blog

          How to pass form data using jquery Ajax to insert data in database?

          Guess what letter conforming each word

          Run scheduled task as local user group (not BUILTIN)