How to correctly write regular expression to match ASCII control chars Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How can I test and use a Perl regular expression interactively?How do I create a dynamic regexp with rx?How to save part of a regular expression during search and replace?Custom Major Mode - Regex to find word before equal sign and set font-lock-variable-name-faceHow to escape regexp special characters in a string?How to match more than one instance of a single subexpression?why is this trim-space function so complicated/ugly in emacs lisp?How to match symbol in regexp?JavaScript regular expressions in re-builderChange regex-builder-mode hook to use <C-s>

Why does this iterative way of solving of equation work?

Was credit for the black hole image misattributed?

How is simplicity better than precision and clarity in prose?

Can smartphones with the same camera sensor have different image quality?

What do you call a plan that's an alternative plan in case your initial plan fails?

What kind of display is this?

3 doors, three guards, one stone

How to retrograde a note sequence in Finale?

Active filter with series inductor and resistor - do these exist?

Aligning matrix of nodes with grid

Who can trigger ship-wide alerts in Star Trek?

Mortgage adviser recommends a longer term than necessary combined with overpayments

Working around an AWS network ACL rule limit

Determine whether f is a function, an injection, a surjection

How does modal jazz use chord progressions?

What does the torsion-free condition for a connection mean in terms of its horizontal bundle?

Two different pronunciation of "понял"

What's the point in a preamp?

What was the last x86 CPU that did not have the x87 floating-point unit built in?

Replacing HDD with SSD; what about non-APFS/APFS?

What would be Julian Assange's expected punishment, on the current English criminal law?

How to select 3,000 out of 10,000 files in file manager?

Did the new image of black hole confirm the general theory of relativity?

Autumning in love



How to correctly write regular expression to match ASCII control chars



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?How can I test and use a Perl regular expression interactively?How do I create a dynamic regexp with rx?How to save part of a regular expression during search and replace?Custom Major Mode - Regex to find word before equal sign and set font-lock-variable-name-faceHow to escape regexp special characters in a string?How to match more than one instance of a single subexpression?why is this trim-space function so complicated/ugly in emacs lisp?How to match symbol in regexp?JavaScript regular expressions in re-builderChange regex-builder-mode hook to use <C-s>










2















I would like to to create a regular expression in elisp (in the standard 'read' form) to match extended ASCII chars the same as PCRE does:



^[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*$


So, I'm currently сonfused about x7f-xff. Is there a way to set a range using something like xhh?










share|improve this question
























  • I think the answer depends on whether you're matching against unibyte or multibyte strings. Do you think À (which is undefined in ASCII, 0xC0 in latin-1 and Unicode, but encoded as 0xC380 in UTF-8) falls into the range 0x7F-0xFF?

    – npostavs
    5 hours ago











  • I think so. At least PCRE matched À as a char in 0x7F-0xFF range. I need the same behavior for standard Elisp regular expression.

    – serghei
    4 hours ago












  • And as I can see À is defined in ASCII: ascii-code.com. 0xC0 is between 0x7F and 0xFF

    – serghei
    4 hours ago















2















I would like to to create a regular expression in elisp (in the standard 'read' form) to match extended ASCII chars the same as PCRE does:



^[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*$


So, I'm currently сonfused about x7f-xff. Is there a way to set a range using something like xhh?










share|improve this question
























  • I think the answer depends on whether you're matching against unibyte or multibyte strings. Do you think À (which is undefined in ASCII, 0xC0 in latin-1 and Unicode, but encoded as 0xC380 in UTF-8) falls into the range 0x7F-0xFF?

    – npostavs
    5 hours ago











  • I think so. At least PCRE matched À as a char in 0x7F-0xFF range. I need the same behavior for standard Elisp regular expression.

    – serghei
    4 hours ago












  • And as I can see À is defined in ASCII: ascii-code.com. 0xC0 is between 0x7F and 0xFF

    – serghei
    4 hours ago













2












2








2


1






I would like to to create a regular expression in elisp (in the standard 'read' form) to match extended ASCII chars the same as PCRE does:



^[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*$


So, I'm currently сonfused about x7f-xff. Is there a way to set a range using something like xhh?










share|improve this question
















I would like to to create a regular expression in elisp (in the standard 'read' form) to match extended ASCII chars the same as PCRE does:



^[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*$


So, I'm currently сonfused about x7f-xff. Is there a way to set a range using something like xhh?







regular-expressions






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 4 hours ago







serghei

















asked 5 hours ago









sergheiserghei

187110




187110












  • I think the answer depends on whether you're matching against unibyte or multibyte strings. Do you think À (which is undefined in ASCII, 0xC0 in latin-1 and Unicode, but encoded as 0xC380 in UTF-8) falls into the range 0x7F-0xFF?

    – npostavs
    5 hours ago











  • I think so. At least PCRE matched À as a char in 0x7F-0xFF range. I need the same behavior for standard Elisp regular expression.

    – serghei
    4 hours ago












  • And as I can see À is defined in ASCII: ascii-code.com. 0xC0 is between 0x7F and 0xFF

    – serghei
    4 hours ago

















  • I think the answer depends on whether you're matching against unibyte or multibyte strings. Do you think À (which is undefined in ASCII, 0xC0 in latin-1 and Unicode, but encoded as 0xC380 in UTF-8) falls into the range 0x7F-0xFF?

    – npostavs
    5 hours ago











  • I think so. At least PCRE matched À as a char in 0x7F-0xFF range. I need the same behavior for standard Elisp regular expression.

    – serghei
    4 hours ago












  • And as I can see À is defined in ASCII: ascii-code.com. 0xC0 is between 0x7F and 0xFF

    – serghei
    4 hours ago
















I think the answer depends on whether you're matching against unibyte or multibyte strings. Do you think À (which is undefined in ASCII, 0xC0 in latin-1 and Unicode, but encoded as 0xC380 in UTF-8) falls into the range 0x7F-0xFF?

– npostavs
5 hours ago





I think the answer depends on whether you're matching against unibyte or multibyte strings. Do you think À (which is undefined in ASCII, 0xC0 in latin-1 and Unicode, but encoded as 0xC380 in UTF-8) falls into the range 0x7F-0xFF?

– npostavs
5 hours ago













I think so. At least PCRE matched À as a char in 0x7F-0xFF range. I need the same behavior for standard Elisp regular expression.

– serghei
4 hours ago






I think so. At least PCRE matched À as a char in 0x7F-0xFF range. I need the same behavior for standard Elisp regular expression.

– serghei
4 hours ago














And as I can see À is defined in ASCII: ascii-code.com. 0xC0 is between 0x7F and 0xFF

– serghei
4 hours ago





And as I can see À is defined in ASCII: ascii-code.com. 0xC0 is between 0x7F and 0xFF

– serghei
4 hours ago










1 Answer
1






active

oldest

votes


















0














You can use -ÿ instead of x7f-xff. That first character, which StackExchange prints as a space, is DEL, which has codepoint 127 (decimal), #o177 (octal), and #x7f (hexadecimal).



That is, you can just insert the characters themselves in the regexp pattern.



One way to input such characters is to use C-x 8 RET. To search for any char in the range x7f through xff you would type this at the C-M-s prompt (without the spaces):



[ C-x 8 RET # x 7 f - C-x 8 RET # x f f ]






share|improve this answer

























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "583"
    ;
    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: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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%2femacs.stackexchange.com%2fquestions%2f48925%2fhow-to-correctly-write-regular-expression-to-match-ascii-control-chars%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









    0














    You can use -ÿ instead of x7f-xff. That first character, which StackExchange prints as a space, is DEL, which has codepoint 127 (decimal), #o177 (octal), and #x7f (hexadecimal).



    That is, you can just insert the characters themselves in the regexp pattern.



    One way to input such characters is to use C-x 8 RET. To search for any char in the range x7f through xff you would type this at the C-M-s prompt (without the spaces):



    [ C-x 8 RET # x 7 f - C-x 8 RET # x f f ]






    share|improve this answer





























      0














      You can use -ÿ instead of x7f-xff. That first character, which StackExchange prints as a space, is DEL, which has codepoint 127 (decimal), #o177 (octal), and #x7f (hexadecimal).



      That is, you can just insert the characters themselves in the regexp pattern.



      One way to input such characters is to use C-x 8 RET. To search for any char in the range x7f through xff you would type this at the C-M-s prompt (without the spaces):



      [ C-x 8 RET # x 7 f - C-x 8 RET # x f f ]






      share|improve this answer



























        0












        0








        0







        You can use -ÿ instead of x7f-xff. That first character, which StackExchange prints as a space, is DEL, which has codepoint 127 (decimal), #o177 (octal), and #x7f (hexadecimal).



        That is, you can just insert the characters themselves in the regexp pattern.



        One way to input such characters is to use C-x 8 RET. To search for any char in the range x7f through xff you would type this at the C-M-s prompt (without the spaces):



        [ C-x 8 RET # x 7 f - C-x 8 RET # x f f ]






        share|improve this answer















        You can use -ÿ instead of x7f-xff. That first character, which StackExchange prints as a space, is DEL, which has codepoint 127 (decimal), #o177 (octal), and #x7f (hexadecimal).



        That is, you can just insert the characters themselves in the regexp pattern.



        One way to input such characters is to use C-x 8 RET. To search for any char in the range x7f through xff you would type this at the C-M-s prompt (without the spaces):



        [ C-x 8 RET # x 7 f - C-x 8 RET # x f f ]







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 hours ago

























        answered 2 hours ago









        DrewDrew

        49.1k463108




        49.1k463108



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Emacs Stack Exchange!


            • 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%2femacs.stackexchange.com%2fquestions%2f48925%2fhow-to-correctly-write-regular-expression-to-match-ascii-control-chars%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

            Bett Inhaltsverzeichnis Geschichte | Bettformen | Bettgrößen | Andere Bezeichnungen | Bettenmangel | Betten in der bildenden Kunst | Schlafmedizinische Gesichtspunkte | Siehe auch | Literatur | Weblinks | Einzelnachweise | NavigationsmenüBett, Bettstatt, BettstelleCommons: BettBabybetten: Anwendung, Ausstattungsmerkmale und VergleichskriterienWasserbetten. Vorurteile im TestHapfnNursch10.1007/s11818-012-0584-74006250-8AKS4329276-8

            Luksemburg Sisukord Nimi | Asend | Loodus | Riigikord | Haldusjaotus | Rahvastik | Riigikaitse | Majandus | Taristu | Ajalugu | Eesti ja Luksemburgi suhted | Haridus | Kultuur | Vaata ka | Viited | Välislingid | Navigeerimismenüü50° N, 6° EÜlevaade Luksemburgi kaitsealadest.Luksemburgi rahvaarv. Statistikaamet.World Bank'i andmebaasÜlevaade Luksemburgi loodusest.Ülevaade Luksemburgi metsadest.Guy Colling. "Red List of the Vascular Plants of Luxembourg." Travaux scientifiques du Musée national d’histoire naturelle Luxembourg. 2005.Luxembourg’s biodiversity at risk.Maailma kahepaiksete andmebaas.Denis Lepage. "Luxembourg." Avibase.Ülevaade temperatuuridest. Luksemburgi meteoroloogiateenistus.Ülevaade Luksemburgist. Euroopa Liidu esinduse koduleht.Système politique. TerritoireÜlevaade Luksemburgi rahvastikust. Luksemburgi statistikaamet.Luksemburgi rahvastik. Luksemburgi statistikaamet.The World FactbookMonique Borsenberger, Paul Dickes. "Religions au Luxembourg. Quelle évolution entre 1999-2008". Luksemburgi statistikaamet. 2011.Luksemburgi peapiiskopkond. Catholic-Hierarchy.Luksemburgi armee koduleht.Luksemburgi armee relvastus.Eesti Välisministeerium.Luksemburgi rahvastik. Luksemburgi statistikaamet.Luksemburgi Eesti Seltsi koduleht.Helen Eelrand. "Raadio, mis muutis maailma." Eesti Päevaleht. 13. märts 2004.Ülevaade Luksemburgi haridussüsteemist.Ülevaade Luksemburgi keskkoolidest.Luksemburgr

            Valle di Casies Indice Geografia fisica | Origini del nome | Storia | Società | Amministrazione | Sport | Note | Bibliografia | Voci correlate | Altri progetti | Collegamenti esterni | Menu di navigazione46°46′N 12°11′E / 46.766667°N 12.183333°E46.766667; 12.183333 (Valle di Casies)46°46′N 12°11′E / 46.766667°N 12.183333°E46.766667; 12.183333 (Valle di Casies)Sito istituzionaleAstat Censimento della popolazione 2011 - Determinazione della consistenza dei tre gruppi linguistici della Provincia Autonoma di Bolzano-Alto Adige - giugno 2012Numeri e fattiValle di CasiesDato IstatTabella dei gradi/giorno dei Comuni italiani raggruppati per Regione e Provincia26 agosto 1993, n. 412Heraldry of the World: GsiesStatistiche I.StatValCasies.comWikimedia CommonsWikimedia CommonsValle di CasiesSito ufficialeValle di CasiesMM14870458910042978-6