CVSROOT: /webcvs/grep Module name: grep Changes by: Jim Meyering <meyering> 23/03/22 22:55:22
Index: html_node/Matching-Non_002dASCII.html =================================================================== RCS file: /webcvs/grep/grep/manual/html_node/Matching-Non_002dASCII.html,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- html_node/Matching-Non_002dASCII.html 3 Sep 2022 19:33:14 -0000 1.3 +++ html_node/Matching-Non_002dASCII.html 23 Mar 2023 02:55:21 -0000 1.4 @@ -1,11 +1,11 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!DOCTYPE html> <html> -<!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ --> +<!-- Created by GNU Texinfo 7.0dev, https://www.gnu.org/software/texinfo/ --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!-- This manual is for grep, a pattern matching engine. -Copyright (C) 1999-2002, 2005, 2008-2022 Free Software Foundation, +Copyright © 1999-2002, 2005, 2008-2023 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document @@ -14,10 +14,10 @@ Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". --> -<title>Matching Non-ASCII (GNU Grep 3.8)</title> +<title>Matching Non-ASCII (GNU Grep 3.10)</title> -<meta name="description" content="Matching Non-ASCII (GNU Grep 3.8)"> -<meta name="keywords" content="Matching Non-ASCII (GNU Grep 3.8)"> +<meta name="description" content="Matching Non-ASCII (GNU Grep 3.10)"> +<meta name="keywords" content="Matching Non-ASCII (GNU Grep 3.10)"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="makeinfo"> @@ -30,21 +30,8 @@ <link href="Character-Encoding.html" rel="prev" title="Character Encoding"> <style type="text/css"> <!-- -a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em} -a.summary-letter {text-decoration: none} -blockquote.indentedblock {margin-right: 0em} -div.display {margin-left: 3.2em} -div.example {margin-left: 3.2em} -kbd {font-style: oblique} -pre.display {font-family: inherit} -pre.format {font-family: inherit} -pre.menu-comment {font-family: serif} -pre.menu-preformatted {font-family: serif} -span.nolinebreak {white-space: nowrap} -span.roman {font-family: initial; font-weight: normal} -span.sansserif {font-family: sans-serif; font-weight: normal} -span:hover a.copiable-anchor {visibility: visible} -ul.no-bullet {list-style: none} +a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em} +span:hover a.copiable-link {visibility: visible} --> </style> <link rel="stylesheet" type="text/css" href="https://www.gnu.org/software/gnulib/manual.css"> @@ -53,52 +40,52 @@ </head> <body lang="en"> -<div class="section" id="Matching-Non_002dASCII"> -<div class="header"> +<div class="section-level-extent" id="Matching-Non_002dASCII"> +<div class="nav-panel"> <p> Previous: <a href="Character-Encoding.html" accesskey="p" rel="prev">Character Encoding</a>, Up: <a href="Regular-Expressions.html" accesskey="u" rel="up">Regular Expressions</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p> </div> <hr> -<span id="Matching-Non_002dASCII-and-Non_002dprintable-Characters"></span><h3 class="section">3.9 Matching Non-ASCII and Non-printable Characters</h3> -<span id="index-non_002dASCII-matching"></span> -<span id="index-non_002dprintable-matching"></span> +<h3 class="section" id="Matching-Non_002dASCII-and-Non_002dprintable-Characters"><span>3.9 Matching Non-ASCII and Non-printable Characters<a class="copiable-link" href="#Matching-Non_002dASCII-and-Non_002dprintable-Characters"> ¶</a></span></h3> +<a class="index-entry-id" id="index-non_002dASCII-matching"></a> +<a class="index-entry-id" id="index-non_002dprintable-matching"></a> <p>In a regular expression, non-ASCII and non-printable characters other than newline are not special, and represent themselves. For example, -in a locale using UTF-8 the command ‘<samp>grep 'Î Ï'</samp>’ (where the -white space between ‘<samp>Î</samp>’ and the ‘<samp>Ï</samp>’ is a tab character) -searches for ‘<samp>Î</samp>’ (Unicode character U+039B GREEK CAPITAL LETTER -LAMBDA), followed by a tab (U+0009 TAB), followed by ‘<samp>Ï</samp>’ (U+03C9 +in a locale using UTF-8 the command ‘<samp class="samp">grep 'Î Ï'</samp>’ (where the +white space between ‘<samp class="samp">Î</samp>’ and the ‘<samp class="samp">Ï</samp>’ is a tab character) +searches for ‘<samp class="samp">Î</samp>’ (Unicode character U+039B GREEK CAPITAL LETTER +LAMBDA), followed by a tab (U+0009 TAB), followed by ‘<samp class="samp">Ï</samp>’ (U+03C9 GREEK SMALL LETTER OMEGA). </p> <p>Suppose you want to limit your pattern to only printable characters (or even only printable ASCII characters) to keep your script readable or portable, but you also want to match specific non-ASCII or non-null -non-printable characters. If you are using the <samp>-P</samp> -(<samp>--perl-regexp</samp>) option, PCREs give you several ways to do +non-printable characters. If you are using the <samp class="option">-P</samp> +(<samp class="option">--perl-regexp</samp>) option, PCREs give you several ways to do this. Otherwise, if you are using Bash, the GNU project’s shell, you can represent these characters via ANSI-C quoting. For example, the -Bash commands ‘<samp>grep $'Î\tÏ'</samp>’ and ‘<samp>grep $'\u039B\t\u03C9'</samp>’ -both search for the same three-character string ‘<samp>Î Ï</samp>’ +Bash commands ‘<samp class="samp">grep $'Î\tÏ'</samp>’ and ‘<samp class="samp">grep $'\u039B\t\u03C9'</samp>’ +both search for the same three-character string ‘<samp class="samp">Î Ï</samp>’ mentioned earlier. However, because Bash translates ANSI-C quoting -before <code>grep</code> sees the pattern, this technique should not be -used to match printable ASCII characters; for example, ‘<samp>grep -$'\u005E'</samp>’ is equivalent to ‘<samp>grep '^'</samp>’ and matches any line, not -just lines containing the character ‘<samp>^</samp>’ (U+005E CIRCUMFLEX +before <code class="command">grep</code> sees the pattern, this technique should not be +used to match printable ASCII characters; for example, ‘<samp class="samp">grep +$'\u005E'</samp>’ is equivalent to ‘<samp class="samp">grep '^'</samp>’ and matches any line, not +just lines containing the character ‘<samp class="samp">^</samp>’ (U+005E CIRCUMFLEX ACCENT). </p> <p>Since PCREs and ANSI-C quoting are GNU extensions to POSIX, portable shell scripts written in ASCII should use other methods to match specific non-ASCII characters. For example, in a UTF-8 locale the -command ‘<samp>grep "$(printf '\316\233\t\317\211\n')"</samp>’ is a portable -albeit hard-to-read alternative to Bash’s ‘<samp>grep $'Î\tÏ'</samp>’. +command ‘<samp class="samp">grep "$(printf '\316\233\t\317\211\n')"</samp>’ is a portable +albeit hard-to-read alternative to Bash’s ‘<samp class="samp">grep $'Î\tÏ'</samp>’. However, none of these techniques will let you put a null character directly into a command-line pattern; null characters can appear only -in a pattern specified via the <samp>-f</samp> (<samp>--file</samp>) option. +in a pattern specified via the <samp class="option">-f</samp> (<samp class="option">--file</samp>) option. </p> </div> <hr> -<div class="header"> +<div class="nav-panel"> <p> Previous: <a href="Character-Encoding.html">Character Encoding</a>, Up: <a href="Regular-Expressions.html">Regular Expressions</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p> </div>
