diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2021-03-31 21:08:58 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2021-03-31 21:08:58 +0300 |
commit | 8acf99e3293c45fbaef69ba9cee3e790f1ff45bd (patch) | |
tree | 09c9f42ea58dda57e023f6e612f5273dbab2d7f6 | |
parent | 728ac1e89ceeea5e646e4e6168a2dc4be0177ff2 (diff) | |
download | egawk-8acf99e3293c45fbaef69ba9cee3e790f1ff45bd.tar.gz egawk-8acf99e3293c45fbaef69ba9cee3e790f1ff45bd.tar.bz2 egawk-8acf99e3293c45fbaef69ba9cee3e790f1ff45bd.zip |
Add some doc on the empty regexp.
-rw-r--r-- | doc/ChangeLog | 7 | ||||
-rw-r--r-- | doc/gawk.info | 1109 | ||||
-rw-r--r-- | doc/gawk.texi | 94 | ||||
-rw-r--r-- | doc/gawktexi.in | 40 |
4 files changed, 715 insertions, 535 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index 77d280bd..04fff857 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,10 @@ +2021-03-31 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in (Regexp Operator Details): Added a sidebar on + matching the empty regexp. Thanks to Arkadiusz Drabczyk + <arkadiusz@drabczyk.org> for pointing out the lack of + documentation. + 2021-03-18 Arnold D. Robbins <arnold@skeeve.com> * texinfo.tex: Updated from GNULIB. diff --git a/doc/gawk.info b/doc/gawk.info index d29e3525..4f0eef36 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -3908,6 +3908,39 @@ themselves when there is nothing in the regexp that precedes them. For example, '/+/' matches a literal plus sign. However, many other versions of 'awk' treat such a usage as a syntax error. + What About The Empty Regexp? + + We describe here an advanced regexp usage. Feel free to skip it upon +first reading. + + You can supply an empty regexp constant ('//') in all places where a +regexp is expected. Is this useful? What does it match? + + It is useful. It matches the (invisible) empty string at the start +and end of a string of characters, as well as the empty string between +characters. This is best illustrated with the 'gsub()' function, which +makes global substitutions in a string (*note String Functions::). +Normal usage of 'gsub()' is like so: + + $ awk ' + > BEGIN { + > x = "ABC_CBA" + > gsub(/B/, "bb", x) + > print x + > }' + -| AbbC_CbbA + + We can use 'gsub()' to see where the empty strings are that match the +empty regexp: + + $ awk ' + > BEGIN { + > x = "ABC" + > gsub(//, "x", x) + > print x + > }' + -| xAxBxCx + ---------- Footnotes ---------- (1) In other literature, you may see a bracket expression referred to @@ -35893,6 +35926,8 @@ Index * empty array elements: Reference to Elements. (line 18) * empty pattern: Empty. (line 6) +* empty regexps: Regexp Operator Details. + (line 149) * EMRED: TCP/IP Networking. (line 6) * enable breakpoint: Breakpoint Control. (line 73) * enable debugger command: Breakpoint Control. (line 73) @@ -37344,6 +37379,8 @@ Index * regexp constants <2>: Comparison Operators. (line 103) * regexp constants, as patterns: Expression Patterns. (line 34) +* regexps, empty: Regexp Operator Details. + (line 149) * register loadable extension: Registration Functions. (line 6) * regular expressions, interval expressions and: Options. (line 317) @@ -37555,6 +37592,8 @@ Index (line 106) * sidebar, Escape Sequences for Metacharacters: Escape Sequences. (line 138) +* sidebar, What About The Empty Regexp?: Regexp Operator Details. + (line 147) * sidebar, Using \n in Bracket Expressions of Dynamic Regexps: Computed Regexps. (line 58) * sidebar, Caveats When Using Regular Expressions for RS: gawk split records. @@ -38086,541 +38125,541 @@ Node: Regexp Usage165115 Node: Escape Sequences167152 Node: Regexp Operators173393 Node: Regexp Operator Details173878 -Ref: Regexp Operator Details-Footnote-1180310 -Node: Interval Expressions180457 -Ref: Interval Expressions-Footnote-1181878 -Node: Bracket Expressions181976 -Ref: table-char-classes184452 -Node: Leftmost Longest187778 -Node: Computed Regexps189081 -Node: GNU Regexp Operators192508 -Node: Case-sensitivity196245 -Ref: Case-sensitivity-Footnote-1199111 -Ref: Case-sensitivity-Footnote-2199346 -Node: Regexp Summary199454 -Node: Reading Files200920 -Node: Records203189 -Node: awk split records204264 -Node: gawk split records208964 -Ref: gawk split records-Footnote-1214038 -Node: Fields214075 -Node: Nonconstant Fields216816 -Ref: Nonconstant Fields-Footnote-1219052 -Node: Changing Fields219256 -Node: Field Separators225287 -Node: Default Field Splitting227985 -Node: Regexp Field Splitting229103 -Node: Single Character Fields232780 -Node: Command Line Field Separator233840 -Node: Full Line Fields237058 -Ref: Full Line Fields-Footnote-1238580 -Ref: Full Line Fields-Footnote-2238626 -Node: Field Splitting Summary238727 -Node: Constant Size240801 -Node: Fixed width data241533 -Node: Skipping intervening245000 -Node: Allowing trailing data245798 -Node: Fields with fixed data246835 -Node: Splitting By Content248353 -Ref: Splitting By Content-Footnote-1252136 -Node: More CSV252299 -Node: Testing field creation253891 -Node: Multiple Line255516 -Node: Getline261793 -Node: Plain Getline264262 -Node: Getline/Variable266835 -Node: Getline/File267986 -Node: Getline/Variable/File269374 -Ref: Getline/Variable/File-Footnote-1270979 -Node: Getline/Pipe271067 -Node: Getline/Variable/Pipe273771 -Node: Getline/Coprocess274906 -Node: Getline/Variable/Coprocess276173 -Node: Getline Notes276915 -Node: Getline Summary279712 -Ref: table-getline-variants280136 -Node: Read Timeout280884 -Ref: Read Timeout-Footnote-1284790 -Node: Retrying Input284848 -Node: Command-line directories286047 -Node: Input Summary286953 -Node: Input Exercises290125 -Node: Printing290559 -Node: Print292393 -Node: Print Examples293850 -Node: Output Separators296630 -Node: OFMT298647 -Node: Printf300003 -Node: Basic Printf300788 -Node: Control Letters302362 -Node: Format Modifiers307526 -Node: Printf Examples313541 -Node: Redirection316027 -Node: Special FD322868 -Ref: Special FD-Footnote-1326036 -Node: Special Files326110 -Node: Other Inherited Files326727 -Node: Special Network327728 -Node: Special Caveats328588 -Node: Close Files And Pipes329537 -Ref: table-close-pipe-return-values336444 -Ref: Close Files And Pipes-Footnote-1337257 -Ref: Close Files And Pipes-Footnote-2337405 -Node: Nonfatal337557 -Node: Output Summary339895 -Node: Output Exercises341117 -Node: Expressions341796 -Node: Values342984 -Node: Constants343662 -Node: Scalar Constants344353 -Ref: Scalar Constants-Footnote-1346863 -Node: Nondecimal-numbers347113 -Node: Regexp Constants350114 -Node: Using Constant Regexps350640 -Node: Standard Regexp Constants351262 -Node: Strong Regexp Constants354450 -Node: Variables357462 -Node: Using Variables358119 -Node: Assignment Options360029 -Node: Conversion362500 -Node: Strings And Numbers363024 -Ref: Strings And Numbers-Footnote-1366087 -Node: Locale influences conversions366196 -Ref: table-locale-affects368954 -Node: All Operators369572 -Node: Arithmetic Ops370201 -Node: Concatenation372917 -Ref: Concatenation-Footnote-1375764 -Node: Assignment Ops375871 -Ref: table-assign-ops380862 -Node: Increment Ops382175 -Node: Truth Values and Conditions385635 -Node: Truth Values386709 -Node: Typing and Comparison387757 -Node: Variable Typing388577 -Ref: Variable Typing-Footnote-1395040 -Ref: Variable Typing-Footnote-2395112 -Node: Comparison Operators395189 -Ref: table-relational-ops395608 -Node: POSIX String Comparison399103 -Ref: POSIX String Comparison-Footnote-1400798 -Ref: POSIX String Comparison-Footnote-2400937 -Node: Boolean Ops401021 -Ref: Boolean Ops-Footnote-1405503 -Node: Conditional Exp405595 -Node: Function Calls407331 -Node: Precedence411208 -Node: Locales414867 -Node: Expressions Summary416499 -Node: Patterns and Actions419072 -Node: Pattern Overview420192 -Node: Regexp Patterns421869 -Node: Expression Patterns422411 -Node: Ranges426192 -Node: BEGIN/END429300 -Node: Using BEGIN/END430061 -Ref: Using BEGIN/END-Footnote-1432815 -Node: I/O And BEGIN/END432921 -Node: BEGINFILE/ENDFILE435234 -Node: Empty438465 -Node: Using Shell Variables438782 -Node: Action Overview441056 -Node: Statements443381 -Node: If Statement445229 -Node: While Statement446724 -Node: Do Statement448752 -Node: For Statement449900 -Node: Switch Statement453071 -Node: Break Statement455512 -Node: Continue Statement457604 -Node: Next Statement459431 -Node: Nextfile Statement461814 -Node: Exit Statement464503 -Node: Built-in Variables466906 -Node: User-modified468039 -Node: Auto-set475806 -Ref: Auto-set-Footnote-1492613 -Ref: Auto-set-Footnote-2492819 -Node: ARGC and ARGV492875 -Node: Pattern Action Summary497088 -Node: Arrays499518 -Node: Array Basics500847 -Node: Array Intro501691 -Ref: figure-array-elements503666 -Ref: Array Intro-Footnote-1506370 -Node: Reference to Elements506498 -Node: Assigning Elements508962 -Node: Array Example509453 -Node: Scanning an Array511212 -Node: Controlling Scanning514234 -Ref: Controlling Scanning-Footnote-1520690 -Node: Numeric Array Subscripts521006 -Node: Uninitialized Subscripts523190 -Node: Delete524809 -Ref: Delete-Footnote-1527561 -Node: Multidimensional527618 -Node: Multiscanning530713 -Node: Arrays of Arrays532304 -Node: Arrays Summary537072 -Node: Functions539165 -Node: Built-in540203 -Node: Calling Built-in541284 -Node: Numeric Functions543280 -Ref: Numeric Functions-Footnote-1547308 -Ref: Numeric Functions-Footnote-2547956 -Ref: Numeric Functions-Footnote-3548004 -Node: String Functions548276 -Ref: String Functions-Footnote-1572417 -Ref: String Functions-Footnote-2572545 -Ref: String Functions-Footnote-3572793 -Node: Gory Details572880 -Ref: table-sub-escapes574671 -Ref: table-sub-proposed576190 -Ref: table-posix-sub577553 -Ref: table-gensub-escapes579094 -Ref: Gory Details-Footnote-1579917 -Node: I/O Functions580071 -Ref: table-system-return-values586525 -Ref: I/O Functions-Footnote-1588605 -Ref: I/O Functions-Footnote-2588753 -Node: Time Functions588873 -Ref: Time Functions-Footnote-1599544 -Ref: Time Functions-Footnote-2599612 -Ref: Time Functions-Footnote-3599770 -Ref: Time Functions-Footnote-4599881 -Ref: Time Functions-Footnote-5599993 -Ref: Time Functions-Footnote-6600220 -Node: Bitwise Functions600486 -Ref: table-bitwise-ops601080 -Ref: Bitwise Functions-Footnote-1607143 -Ref: Bitwise Functions-Footnote-2607316 -Node: Type Functions607507 -Node: I18N Functions610370 -Node: User-defined612021 -Node: Definition Syntax612833 -Ref: Definition Syntax-Footnote-1618527 -Node: Function Example618598 -Ref: Function Example-Footnote-1621520 -Node: Function Calling621542 -Node: Calling A Function622130 -Node: Variable Scope623088 -Node: Pass By Value/Reference626082 -Node: Function Caveats628726 -Ref: Function Caveats-Footnote-1630773 -Node: Return Statement630893 -Node: Dynamic Typing633872 -Node: Indirect Calls634802 -Ref: Indirect Calls-Footnote-1645054 -Node: Functions Summary645182 -Node: Library Functions647887 -Ref: Library Functions-Footnote-1651494 -Ref: Library Functions-Footnote-2651637 -Node: Library Names651808 -Ref: Library Names-Footnote-1655475 -Ref: Library Names-Footnote-2655698 -Node: General Functions655784 -Node: Strtonum Function656887 -Node: Assert Function659909 -Node: Round Function663235 -Node: Cliff Random Function664775 -Node: Ordinal Functions665791 -Ref: Ordinal Functions-Footnote-1668854 -Ref: Ordinal Functions-Footnote-2669106 -Node: Join Function669316 -Ref: Join Function-Footnote-1671086 -Node: Getlocaltime Function671286 -Node: Readfile Function675028 -Node: Shell Quoting677005 -Node: Data File Management678406 -Node: Filetrans Function679038 -Node: Rewind Function683134 -Node: File Checking685043 -Ref: File Checking-Footnote-1686377 -Node: Empty Files686578 -Node: Ignoring Assigns688557 -Node: Getopt Function690107 -Ref: Getopt Function-Footnote-1705318 -Node: Passwd Functions705518 -Ref: Passwd Functions-Footnote-1714357 -Node: Group Functions714445 -Ref: Group Functions-Footnote-1722343 -Node: Walking Arrays722550 -Node: Library Functions Summary725558 -Node: Library Exercises726964 -Node: Sample Programs727429 -Node: Running Examples728199 -Node: Clones728927 -Node: Cut Program730151 -Node: Egrep Program740291 -Node: Id Program749292 -Node: Split Program759239 -Ref: Split Program-Footnote-1769129 -Node: Tee Program769302 -Node: Uniq Program772092 -Node: Wc Program779680 -Node: Bytes vs. Characters780077 -Node: Using extensions781625 -Node: wc program782379 -Node: Miscellaneous Programs787244 -Node: Dupword Program788457 -Node: Alarm Program790487 -Node: Translate Program795342 -Ref: Translate Program-Footnote-1799907 -Node: Labels Program800177 -Ref: Labels Program-Footnote-1803528 -Node: Word Sorting803612 -Node: History Sorting807684 -Node: Extract Program809909 -Node: Simple Sed817963 -Node: Igawk Program821037 -Ref: Igawk Program-Footnote-1835368 -Ref: Igawk Program-Footnote-2835570 -Ref: Igawk Program-Footnote-3835692 -Node: Anagram Program835807 -Node: Signature Program838869 -Node: Programs Summary840116 -Node: Programs Exercises841330 -Ref: Programs Exercises-Footnote-1845460 -Node: Advanced Features845546 -Node: Nondecimal Data847613 -Node: Array Sorting849204 -Node: Controlling Array Traversal849904 -Ref: Controlling Array Traversal-Footnote-1858272 -Node: Array Sorting Functions858390 -Ref: Array Sorting Functions-Footnote-1863481 -Node: Two-way I/O863677 -Ref: Two-way I/O-Footnote-1871398 -Ref: Two-way I/O-Footnote-2871585 -Node: TCP/IP Networking871667 -Node: Profiling874785 -Node: Extension Philosophy884094 -Node: Advanced Features Summary885573 -Node: Internationalization887588 -Node: I18N and L10N889068 -Node: Explaining gettext889755 -Ref: Explaining gettext-Footnote-1895647 -Ref: Explaining gettext-Footnote-2895832 -Node: Programmer i18n895997 -Ref: Programmer i18n-Footnote-1900946 -Node: Translator i18n900995 -Node: String Extraction901789 -Ref: String Extraction-Footnote-1902921 -Node: Printf Ordering903007 -Ref: Printf Ordering-Footnote-1905793 -Node: I18N Portability905857 -Ref: I18N Portability-Footnote-1908313 -Node: I18N Example908376 -Ref: I18N Example-Footnote-1911651 -Ref: I18N Example-Footnote-2911724 -Node: Gawk I18N911833 -Node: I18N Summary912482 -Node: Debugger913823 -Node: Debugging914823 -Node: Debugging Concepts915264 -Node: Debugging Terms917073 -Node: Awk Debugging919648 -Ref: Awk Debugging-Footnote-1920593 -Node: Sample Debugging Session920725 -Node: Debugger Invocation921259 -Node: Finding The Bug922645 -Node: List of Debugger Commands929119 -Node: Breakpoint Control930452 -Node: Debugger Execution Control934146 -Node: Viewing And Changing Data937508 -Node: Execution Stack941049 -Node: Debugger Info942686 -Node: Miscellaneous Debugger Commands946757 -Node: Readline Support951819 -Node: Limitations952715 -Node: Debugging Summary955269 -Node: Namespaces956548 -Node: Global Namespace957659 -Node: Qualified Names959057 -Node: Default Namespace960056 -Node: Changing The Namespace960797 -Node: Naming Rules962411 -Node: Internal Name Management964259 -Node: Namespace Example965301 -Node: Namespace And Features967863 -Node: Namespace Summary969298 -Node: Arbitrary Precision Arithmetic970775 -Node: Computer Arithmetic972262 -Ref: table-numeric-ranges976028 -Ref: table-floating-point-ranges976521 -Ref: Computer Arithmetic-Footnote-1977179 -Node: Math Definitions977236 -Ref: table-ieee-formats980552 -Ref: Math Definitions-Footnote-1981155 -Node: MPFR features981260 -Node: FP Math Caution982978 -Ref: FP Math Caution-Footnote-1984050 -Node: Inexactness of computations984419 -Node: Inexact representation985379 -Node: Comparing FP Values986739 -Node: Errors accumulate987980 -Node: Getting Accuracy989413 -Node: Try To Round992123 -Node: Setting precision993022 -Ref: table-predefined-precision-strings993719 -Node: Setting the rounding mode995549 -Ref: table-gawk-rounding-modes995923 -Ref: Setting the rounding mode-Footnote-1999854 -Node: Arbitrary Precision Integers1000033 -Ref: Arbitrary Precision Integers-Footnote-11003208 -Node: Checking for MPFR1003357 -Node: POSIX Floating Point Problems1004831 -Ref: POSIX Floating Point Problems-Footnote-11009116 -Node: Floating point summary1009154 -Node: Dynamic Extensions1011344 -Node: Extension Intro1012897 -Node: Plugin License1014163 -Node: Extension Mechanism Outline1014960 -Ref: figure-load-extension1015399 -Ref: figure-register-new-function1016964 -Ref: figure-call-new-function1018056 -Node: Extension API Description1020118 -Node: Extension API Functions Introduction1021831 -Ref: table-api-std-headers1023667 -Node: General Data Types1027916 -Ref: General Data Types-Footnote-11036546 -Node: Memory Allocation Functions1036845 -Ref: Memory Allocation Functions-Footnote-11041346 -Node: Constructor Functions1041445 -Node: API Ownership of MPFR and GMP Values1044911 -Node: Registration Functions1046224 -Node: Extension Functions1046924 -Node: Exit Callback Functions1052246 -Node: Extension Version String1053496 -Node: Input Parsers1054159 -Node: Output Wrappers1066880 -Node: Two-way processors1071392 -Node: Printing Messages1073657 -Ref: Printing Messages-Footnote-11074828 -Node: Updating ERRNO1074981 -Node: Requesting Values1075720 -Ref: table-value-types-returned1076457 -Node: Accessing Parameters1077393 -Node: Symbol Table Access1078630 -Node: Symbol table by name1079142 -Ref: Symbol table by name-Footnote-11082166 -Node: Symbol table by cookie1082294 -Ref: Symbol table by cookie-Footnote-11086479 -Node: Cached values1086543 -Ref: Cached values-Footnote-11090079 -Node: Array Manipulation1090232 -Ref: Array Manipulation-Footnote-11091323 -Node: Array Data Types1091360 -Ref: Array Data Types-Footnote-11094018 -Node: Array Functions1094110 -Node: Flattening Arrays1098608 -Node: Creating Arrays1105584 -Node: Redirection API1110351 -Node: Extension API Variables1113184 -Node: Extension Versioning1113895 -Ref: gawk-api-version1114324 -Node: Extension GMP/MPFR Versioning1116055 -Node: Extension API Informational Variables1117683 -Node: Extension API Boilerplate1118756 -Node: Changes from API V11122730 -Node: Finding Extensions1124302 -Node: Extension Example1124861 -Node: Internal File Description1125659 -Node: Internal File Ops1129739 -Ref: Internal File Ops-Footnote-11141089 -Node: Using Internal File Ops1141229 -Ref: Using Internal File Ops-Footnote-11143612 -Node: Extension Samples1143886 -Node: Extension Sample File Functions1145415 -Node: Extension Sample Fnmatch1153064 -Node: Extension Sample Fork1154551 -Node: Extension Sample Inplace1155769 -Node: Extension Sample Ord1159395 -Node: Extension Sample Readdir1160231 -Ref: table-readdir-file-types1161120 -Node: Extension Sample Revout1162187 -Node: Extension Sample Rev2way1162776 -Node: Extension Sample Read write array1163516 -Node: Extension Sample Readfile1165458 -Node: Extension Sample Time1166553 -Node: Extension Sample API Tests1168305 -Node: gawkextlib1168797 -Node: Extension summary1171715 -Node: Extension Exercises1175417 -Node: Language History1176659 -Node: V7/SVR3.11178315 -Node: SVR41180467 -Node: POSIX1181901 -Node: BTL1183282 -Node: POSIX/GNU1184011 -Node: Feature History1189789 -Node: Common Extensions1206108 -Node: Ranges and Locales1207391 -Ref: Ranges and Locales-Footnote-11212007 -Ref: Ranges and Locales-Footnote-21212034 -Ref: Ranges and Locales-Footnote-31212269 -Node: Contributors1212492 -Node: History summary1218489 -Node: Installation1219869 -Node: Gawk Distribution1220813 -Node: Getting1221297 -Node: Extracting1222260 -Node: Distribution contents1223898 -Node: Unix Installation1230378 -Node: Quick Installation1231060 -Node: Shell Startup Files1233474 -Node: Additional Configuration Options1234563 -Node: Configuration Philosophy1236878 -Node: Non-Unix Installation1239247 -Node: PC Installation1239707 -Node: PC Binary Installation1240545 -Node: PC Compiling1240980 -Node: PC Using1242097 -Node: Cygwin1245650 -Node: MSYS1246874 -Node: VMS Installation1247476 -Node: VMS Compilation1248267 -Ref: VMS Compilation-Footnote-11249496 -Node: VMS Dynamic Extensions1249554 -Node: VMS Installation Details1251239 -Node: VMS Running1253492 -Node: VMS GNV1257771 -Node: VMS Old Gawk1258506 -Node: Bugs1258977 -Node: Bug address1259640 -Node: Usenet1262622 -Node: Maintainers1263626 -Node: Other Versions1264811 -Node: Installation summary1272676 -Node: Notes1273885 -Node: Compatibility Mode1274679 -Node: Additions1275461 -Node: Accessing The Source1276386 -Node: Adding Code1277823 -Node: New Ports1284042 -Node: Derived Files1288417 -Ref: Derived Files-Footnote-11294077 -Ref: Derived Files-Footnote-21294112 -Ref: Derived Files-Footnote-31294710 -Node: Future Extensions1294824 -Node: Implementation Limitations1295482 -Node: Extension Design1296692 -Node: Old Extension Problems1297836 -Ref: Old Extension Problems-Footnote-11299354 -Node: Extension New Mechanism Goals1299411 -Ref: Extension New Mechanism Goals-Footnote-11302775 -Node: Extension Other Design Decisions1302964 -Node: Extension Future Growth1305077 -Node: Notes summary1305683 -Node: Basic Concepts1306841 -Node: Basic High Level1307522 -Ref: figure-general-flow1307804 -Ref: figure-process-flow1308489 -Ref: Basic High Level-Footnote-11311790 -Node: Basic Data Typing1311975 -Node: Glossary1315303 -Node: Copying1347188 -Node: GNU Free Documentation License1384731 -Node: Index1409851 +Ref: Regexp Operator Details-Footnote-1181242 +Node: Interval Expressions181389 +Ref: Interval Expressions-Footnote-1182810 +Node: Bracket Expressions182908 +Ref: table-char-classes185384 +Node: Leftmost Longest188710 +Node: Computed Regexps190013 +Node: GNU Regexp Operators193440 +Node: Case-sensitivity197177 +Ref: Case-sensitivity-Footnote-1200043 +Ref: Case-sensitivity-Footnote-2200278 +Node: Regexp Summary200386 +Node: Reading Files201852 +Node: Records204121 +Node: awk split records205196 +Node: gawk split records209896 +Ref: gawk split records-Footnote-1214970 +Node: Fields215007 +Node: Nonconstant Fields217748 +Ref: Nonconstant Fields-Footnote-1219984 +Node: Changing Fields220188 +Node: Field Separators226219 +Node: Default Field Splitting228917 +Node: Regexp Field Splitting230035 +Node: Single Character Fields233712 +Node: Command Line Field Separator234772 +Node: Full Line Fields237990 +Ref: Full Line Fields-Footnote-1239512 +Ref: Full Line Fields-Footnote-2239558 +Node: Field Splitting Summary239659 +Node: Constant Size241733 +Node: Fixed width data242465 +Node: Skipping intervening245932 +Node: Allowing trailing data246730 +Node: Fields with fixed data247767 +Node: Splitting By Content249285 +Ref: Splitting By Content-Footnote-1253068 +Node: More CSV253231 +Node: Testing field creation254823 +Node: Multiple Line256448 +Node: Getline262725 +Node: Plain Getline265194 +Node: Getline/Variable267767 +Node: Getline/File268918 +Node: Getline/Variable/File270306 +Ref: Getline/Variable/File-Footnote-1271911 +Node: Getline/Pipe271999 +Node: Getline/Variable/Pipe274703 +Node: Getline/Coprocess275838 +Node: Getline/Variable/Coprocess277105 +Node: Getline Notes277847 +Node: Getline Summary280644 +Ref: table-getline-variants281068 +Node: Read Timeout281816 +Ref: Read Timeout-Footnote-1285722 +Node: Retrying Input285780 +Node: Command-line directories286979 +Node: Input Summary287885 +Node: Input Exercises291057 +Node: Printing291491 +Node: Print293325 +Node: Print Examples294782 +Node: Output Separators297562 +Node: OFMT299579 +Node: Printf300935 +Node: Basic Printf301720 +Node: Control Letters303294 +Node: Format Modifiers308458 +Node: Printf Examples314473 +Node: Redirection316959 +Node: Special FD323800 +Ref: Special FD-Footnote-1326968 +Node: Special Files327042 +Node: Other Inherited Files327659 +Node: Special Network328660 +Node: Special Caveats329520 +Node: Close Files And Pipes330469 +Ref: table-close-pipe-return-values337376 +Ref: Close Files And Pipes-Footnote-1338189 +Ref: Close Files And Pipes-Footnote-2338337 +Node: Nonfatal338489 +Node: Output Summary340827 +Node: Output Exercises342049 +Node: Expressions342728 +Node: Values343916 +Node: Constants344594 +Node: Scalar Constants345285 +Ref: Scalar Constants-Footnote-1347795 +Node: Nondecimal-numbers348045 +Node: Regexp Constants351046 +Node: Using Constant Regexps351572 +Node: Standard Regexp Constants352194 +Node: Strong Regexp Constants355382 +Node: Variables358394 +Node: Using Variables359051 +Node: Assignment Options360961 +Node: Conversion363432 +Node: Strings And Numbers363956 +Ref: Strings And Numbers-Footnote-1367019 +Node: Locale influences conversions367128 +Ref: table-locale-affects369886 +Node: All Operators370504 +Node: Arithmetic Ops371133 +Node: Concatenation373849 +Ref: Concatenation-Footnote-1376696 +Node: Assignment Ops376803 +Ref: table-assign-ops381794 +Node: Increment Ops383107 +Node: Truth Values and Conditions386567 +Node: Truth Values387641 +Node: Typing and Comparison388689 +Node: Variable Typing389509 +Ref: Variable Typing-Footnote-1395972 +Ref: Variable Typing-Footnote-2396044 +Node: Comparison Operators396121 +Ref: table-relational-ops396540 +Node: POSIX String Comparison400035 +Ref: POSIX String Comparison-Footnote-1401730 +Ref: POSIX String Comparison-Footnote-2401869 +Node: Boolean Ops401953 +Ref: Boolean Ops-Footnote-1406435 +Node: Conditional Exp406527 +Node: Function Calls408263 +Node: Precedence412140 +Node: Locales415799 +Node: Expressions Summary417431 +Node: Patterns and Actions420004 +Node: Pattern Overview421124 +Node: Regexp Patterns422801 +Node: Expression Patterns423343 +Node: Ranges427124 +Node: BEGIN/END430232 +Node: Using BEGIN/END430993 +Ref: Using BEGIN/END-Footnote-1433747 +Node: I/O And BEGIN/END433853 +Node: BEGINFILE/ENDFILE436166 +Node: Empty439397 +Node: Using Shell Variables439714 +Node: Action Overview441988 +Node: Statements444313 +Node: If Statement446161 +Node: While Statement447656 +Node: Do Statement449684 +Node: For Statement450832 +Node: Switch Statement454003 +Node: Break Statement456444 +Node: Continue Statement458536 +Node: Next Statement460363 +Node: Nextfile Statement462746 +Node: Exit Statement465435 +Node: Built-in Variables467838 +Node: User-modified468971 +Node: Auto-set476738 +Ref: Auto-set-Footnote-1493545 +Ref: Auto-set-Footnote-2493751 +Node: ARGC and ARGV493807 +Node: Pattern Action Summary498020 +Node: Arrays500450 +Node: Array Basics501779 +Node: Array Intro502623 +Ref: figure-array-elements504598 +Ref: Array Intro-Footnote-1507302 +Node: Reference to Elements507430 +Node: Assigning Elements509894 +Node: Array Example510385 +Node: Scanning an Array512144 +Node: Controlling Scanning515166 +Ref: Controlling Scanning-Footnote-1521622 +Node: Numeric Array Subscripts521938 +Node: Uninitialized Subscripts524122 +Node: Delete525741 +Ref: Delete-Footnote-1528493 +Node: Multidimensional528550 +Node: Multiscanning531645 +Node: Arrays of Arrays533236 +Node: Arrays Summary538004 +Node: Functions540097 +Node: Built-in541135 +Node: Calling Built-in542216 +Node: Numeric Functions544212 +Ref: Numeric Functions-Footnote-1548240 +Ref: Numeric Functions-Footnote-2548888 +Ref: Numeric Functions-Footnote-3548936 +Node: String Functions549208 +Ref: String Functions-Footnote-1573349 +Ref: String Functions-Footnote-2573477 +Ref: String Functions-Footnote-3573725 +Node: Gory Details573812 +Ref: table-sub-escapes575603 +Ref: table-sub-proposed577122 +Ref: table-posix-sub578485 +Ref: table-gensub-escapes580026 +Ref: Gory Details-Footnote-1580849 +Node: I/O Functions581003 +Ref: table-system-return-values587457 +Ref: I/O Functions-Footnote-1589537 +Ref: I/O Functions-Footnote-2589685 +Node: Time Functions589805 +Ref: Time Functions-Footnote-1600476 +Ref: Time Functions-Footnote-2600544 +Ref: Time Functions-Footnote-3600702 +Ref: Time Functions-Footnote-4600813 +Ref: Time Functions-Footnote-5600925 +Ref: Time Functions-Footnote-6601152 +Node: Bitwise Functions601418 +Ref: table-bitwise-ops602012 +Ref: Bitwise Functions-Footnote-1608075 +Ref: Bitwise Functions-Footnote-2608248 +Node: Type Functions608439 +Node: I18N Functions611302 +Node: User-defined612953 +Node: Definition Syntax613765 +Ref: Definition Syntax-Footnote-1619459 +Node: Function Example619530 +Ref: Function Example-Footnote-1622452 +Node: Function Calling622474 +Node: Calling A Function623062 +Node: Variable Scope624020 +Node: Pass By Value/Reference627014 +Node: Function Caveats629658 +Ref: Function Caveats-Footnote-1631705 +Node: Return Statement631825 +Node: Dynamic Typing634804 +Node: Indirect Calls635734 +Ref: Indirect Calls-Footnote-1645986 +Node: Functions Summary646114 +Node: Library Functions648819 +Ref: Library Functions-Footnote-1652426 +Ref: Library Functions-Footnote-2652569 +Node: Library Names652740 +Ref: Library Names-Footnote-1656407 +Ref: Library Names-Footnote-2656630 +Node: General Functions656716 +Node: Strtonum Function657819 +Node: Assert Function660841 +Node: Round Function664167 +Node: Cliff Random Function665707 +Node: Ordinal Functions666723 +Ref: Ordinal Functions-Footnote-1669786 +Ref: Ordinal Functions-Footnote-2670038 +Node: Join Function670248 +Ref: Join Function-Footnote-1672018 +Node: Getlocaltime Function672218 +Node: Readfile Function675960 +Node: Shell Quoting677937 +Node: Data File Management679338 +Node: Filetrans Function679970 +Node: Rewind Function684066 +Node: File Checking685975 +Ref: File Checking-Footnote-1687309 +Node: Empty Files687510 +Node: Ignoring Assigns689489 +Node: Getopt Function691039 +Ref: Getopt Function-Footnote-1706250 +Node: Passwd Functions706450 +Ref: Passwd Functions-Footnote-1715289 +Node: Group Functions715377 +Ref: Group Functions-Footnote-1723275 +Node: Walking Arrays723482 +Node: Library Functions Summary726490 +Node: Library Exercises727896 +Node: Sample Programs728361 +Node: Running Examples729131 +Node: Clones729859 +Node: Cut Program731083 +Node: Egrep Program741223 +Node: Id Program750224 +Node: Split Program760171 +Ref: Split Program-Footnote-1770061 +Node: Tee Program770234 +Node: Uniq Program773024 +Node: Wc Program780612 +Node: Bytes vs. Characters781009 +Node: Using extensions782557 +Node: wc program783311 +Node: Miscellaneous Programs788176 +Node: Dupword Program789389 +Node: Alarm Program791419 +Node: Translate Program796274 +Ref: Translate Program-Footnote-1800839 +Node: Labels Program801109 +Ref: Labels Program-Footnote-1804460 +Node: Word Sorting804544 +Node: History Sorting808616 +Node: Extract Program810841 +Node: Simple Sed818895 +Node: Igawk Program821969 +Ref: Igawk Program-Footnote-1836300 +Ref: Igawk Program-Footnote-2836502 +Ref: Igawk Program-Footnote-3836624 +Node: Anagram Program836739 +Node: Signature Program839801 +Node: Programs Summary841048 +Node: Programs Exercises842262 +Ref: Programs Exercises-Footnote-1846392 +Node: Advanced Features846478 +Node: Nondecimal Data848545 +Node: Array Sorting850136 +Node: Controlling Array Traversal850836 +Ref: Controlling Array Traversal-Footnote-1859204 +Node: Array Sorting Functions859322 +Ref: Array Sorting Functions-Footnote-1864413 +Node: Two-way I/O864609 +Ref: Two-way I/O-Footnote-1872330 +Ref: Two-way I/O-Footnote-2872517 +Node: TCP/IP Networking872599 +Node: Profiling875717 +Node: Extension Philosophy885026 +Node: Advanced Features Summary886505 +Node: Internationalization888520 +Node: I18N and L10N890000 +Node: Explaining gettext890687 +Ref: Explaining gettext-Footnote-1896579 +Ref: Explaining gettext-Footnote-2896764 +Node: Programmer i18n896929 +Ref: Programmer i18n-Footnote-1901878 +Node: Translator i18n901927 +Node: String Extraction902721 +Ref: String Extraction-Footnote-1903853 +Node: Printf Ordering903939 +Ref: Printf Ordering-Footnote-1906725 +Node: I18N Portability906789 +Ref: I18N Portability-Footnote-1909245 +Node: I18N Example909308 +Ref: I18N Example-Footnote-1912583 +Ref: I18N Example-Footnote-2912656 +Node: Gawk I18N912765 +Node: I18N Summary913414 +Node: Debugger914755 +Node: Debugging915755 +Node: Debugging Concepts916196 +Node: Debugging Terms918005 +Node: Awk Debugging920580 +Ref: Awk Debugging-Footnote-1921525 +Node: Sample Debugging Session921657 +Node: Debugger Invocation922191 +Node: Finding The Bug923577 +Node: List of Debugger Commands930051 +Node: Breakpoint Control931384 +Node: Debugger Execution Control935078 +Node: Viewing And Changing Data938440 +Node: Execution Stack941981 +Node: Debugger Info943618 +Node: Miscellaneous Debugger Commands947689 +Node: Readline Support952751 +Node: Limitations953647 +Node: Debugging Summary956201 +Node: Namespaces957480 +Node: Global Namespace958591 +Node: Qualified Names959989 +Node: Default Namespace960988 +Node: Changing The Namespace961729 +Node: Naming Rules963343 +Node: Internal Name Management965191 +Node: Namespace Example966233 +Node: Namespace And Features968795 +Node: Namespace Summary970230 +Node: Arbitrary Precision Arithmetic971707 +Node: Computer Arithmetic973194 +Ref: table-numeric-ranges976960 +Ref: table-floating-point-ranges977453 +Ref: Computer Arithmetic-Footnote-1978111 +Node: Math Definitions978168 +Ref: table-ieee-formats981484 +Ref: Math Definitions-Footnote-1982087 +Node: MPFR features982192 +Node: FP Math Caution983910 +Ref: FP Math Caution-Footnote-1984982 +Node: Inexactness of computations985351 +Node: Inexact representation986311 +Node: Comparing FP Values987671 +Node: Errors accumulate988912 +Node: Getting Accuracy990345 +Node: Try To Round993055 +Node: Setting precision993954 +Ref: table-predefined-precision-strings994651 +Node: Setting the rounding mode996481 +Ref: table-gawk-rounding-modes996855 +Ref: Setting the rounding mode-Footnote-11000786 +Node: Arbitrary Precision Integers1000965 +Ref: Arbitrary Precision Integers-Footnote-11004140 +Node: Checking for MPFR1004289 +Node: POSIX Floating Point Problems1005763 +Ref: POSIX Floating Point Problems-Footnote-11010048 +Node: Floating point summary1010086 +Node: Dynamic Extensions1012276 +Node: Extension Intro1013829 +Node: Plugin License1015095 +Node: Extension Mechanism Outline1015892 +Ref: figure-load-extension1016331 +Ref: figure-register-new-function1017896 +Ref: figure-call-new-function1018988 +Node: Extension API Description1021050 +Node: Extension API Functions Introduction1022763 +Ref: table-api-std-headers1024599 +Node: General Data Types1028848 +Ref: General Data Types-Footnote-11037478 +Node: Memory Allocation Functions1037777 +Ref: Memory Allocation Functions-Footnote-11042278 +Node: Constructor Functions1042377 +Node: API Ownership of MPFR and GMP Values1045843 +Node: Registration Functions1047156 +Node: Extension Functions1047856 +Node: Exit Callback Functions1053178 +Node: Extension Version String1054428 +Node: Input Parsers1055091 +Node: Output Wrappers1067812 +Node: Two-way processors1072324 +Node: Printing Messages1074589 +Ref: Printing Messages-Footnote-11075760 +Node: Updating ERRNO1075913 +Node: Requesting Values1076652 +Ref: table-value-types-returned1077389 +Node: Accessing Parameters1078325 +Node: Symbol Table Access1079562 +Node: Symbol table by name1080074 +Ref: Symbol table by name-Footnote-11083098 +Node: Symbol table by cookie1083226 +Ref: Symbol table by cookie-Footnote-11087411 +Node: Cached values1087475 +Ref: Cached values-Footnote-11091011 +Node: Array Manipulation1091164 +Ref: Array Manipulation-Footnote-11092255 +Node: Array Data Types1092292 +Ref: Array Data Types-Footnote-11094950 +Node: Array Functions1095042 +Node: Flattening Arrays1099540 +Node: Creating Arrays1106516 +Node: Redirection API1111283 +Node: Extension API Variables1114116 +Node: Extension Versioning1114827 +Ref: gawk-api-version1115256 +Node: Extension GMP/MPFR Versioning1116987 +Node: Extension API Informational Variables1118615 +Node: Extension API Boilerplate1119688 +Node: Changes from API V11123662 +Node: Finding Extensions1125234 +Node: Extension Example1125793 +Node: Internal File Description1126591 +Node: Internal File Ops1130671 +Ref: Internal File Ops-Footnote-11142021 +Node: Using Internal File Ops1142161 +Ref: Using Internal File Ops-Footnote-11144544 +Node: Extension Samples1144818 +Node: Extension Sample File Functions1146347 +Node: Extension Sample Fnmatch1153996 +Node: Extension Sample Fork1155483 +Node: Extension Sample Inplace1156701 +Node: Extension Sample Ord1160327 +Node: Extension Sample Readdir1161163 +Ref: table-readdir-file-types1162052 +Node: Extension Sample Revout1163119 +Node: Extension Sample Rev2way1163708 +Node: Extension Sample Read write array1164448 +Node: Extension Sample Readfile1166390 +Node: Extension Sample Time1167485 +Node: Extension Sample API Tests1169237 +Node: gawkextlib1169729 +Node: Extension summary1172647 +Node: Extension Exercises1176349 +Node: Language History1177591 +Node: V7/SVR3.11179247 +Node: SVR41181399 +Node: POSIX1182833 +Node: BTL1184214 +Node: POSIX/GNU1184943 +Node: Feature History1190721 +Node: Common Extensions1207040 +Node: Ranges and Locales1208323 +Ref: Ranges and Locales-Footnote-11212939 +Ref: Ranges and Locales-Footnote-21212966 +Ref: Ranges and Locales-Footnote-31213201 +Node: Contributors1213424 +Node: History summary1219421 +Node: Installation1220801 +Node: Gawk Distribution1221745 +Node: Getting1222229 +Node: Extracting1223192 +Node: Distribution contents1224830 +Node: Unix Installation1231310 +Node: Quick Installation1231992 +Node: Shell Startup Files1234406 +Node: Additional Configuration Options1235495 +Node: Configuration Philosophy1237810 +Node: Non-Unix Installation1240179 +Node: PC Installation1240639 +Node: PC Binary Installation1241477 +Node: PC Compiling1241912 +Node: PC Using1243029 +Node: Cygwin1246582 +Node: MSYS1247806 +Node: VMS Installation1248408 +Node: VMS Compilation1249199 +Ref: VMS Compilation-Footnote-11250428 +Node: VMS Dynamic Extensions1250486 +Node: VMS Installation Details1252171 +Node: VMS Running1254424 +Node: VMS GNV1258703 +Node: VMS Old Gawk1259438 +Node: Bugs1259909 +Node: Bug address1260572 +Node: Usenet1263554 +Node: Maintainers1264558 +Node: Other Versions1265743 +Node: Installation summary1273608 +Node: Notes1274817 +Node: Compatibility Mode1275611 +Node: Additions1276393 +Node: Accessing The Source1277318 +Node: Adding Code1278755 +Node: New Ports1284974 +Node: Derived Files1289349 +Ref: Derived Files-Footnote-11295009 +Ref: Derived Files-Footnote-21295044 +Ref: Derived Files-Footnote-31295642 +Node: Future Extensions1295756 +Node: Implementation Limitations1296414 +Node: Extension Design1297624 +Node: Old Extension Problems1298768 +Ref: Old Extension Problems-Footnote-11300286 +Node: Extension New Mechanism Goals1300343 +Ref: Extension New Mechanism Goals-Footnote-11303707 +Node: Extension Other Design Decisions1303896 +Node: Extension Future Growth1306009 +Node: Notes summary1306615 +Node: Basic Concepts1307773 +Node: Basic High Level1308454 +Ref: figure-general-flow1308736 +Ref: figure-process-flow1309421 +Ref: Basic High Level-Footnote-11312722 +Node: Basic Data Typing1312907 +Node: Glossary1316235 +Node: Copying1348120 +Node: GNU Free Documentation License1385663 +Node: Index1410783 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index c208ecac..7a746e1b 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -5965,6 +5965,100 @@ regexp that precedes them. For example, @code{/+/} matches a literal plus sign. However, many other versions of @command{awk} treat such a usage as a syntax error. +@cindex sidebar @subentry What About The Empty Regexp? +@ifdocbook +@docbook +<sidebar><title>What About The Empty Regexp?</title> +@end docbook + +@cindex empty regexps +@cindex regexps, empty +We describe here an advanced regexp usage. Feel free to skip it +upon first reading. + +You can supply an empty regexp constant (@samp{//}) in all places +where a regexp is expected. Is this useful? What does it match? + +It is useful. It matches the (invisible) empty string at the start +and end of a string of characters, as well as the empty string +between characters. This is best illustrated with the @code{gsub()} +function, which makes global substitutions in a string +(@pxref{String Functions}). Normal usage of @code{gsub()} is like +so: + +@example +$ @kbd{awk '} +> @kbd{BEGIN @{} +> @kbd{ x = "ABC_CBA"} +> @kbd{ gsub(/B/, "bb", x)} +> @kbd{ print x} +> @kbd{@}'} +@print{} AbbC_CbbA +@end example + +We can use @code{gsub()} to see where the empty strings +are that match the empty regexp: + +@example +$ @kbd{awk '} +> @kbd{BEGIN @{} +> @kbd{ x = "ABC"} +> @kbd{ gsub(//, "x", x)} +> @kbd{ print x} +> @kbd{@}'} +@print{} xAxBxCx +@end example + +@docbook +</sidebar> +@end docbook +@end ifdocbook + +@ifnotdocbook +@cartouche +@center @b{What About The Empty Regexp?} + + +@cindex empty regexps +@cindex regexps, empty +We describe here an advanced regexp usage. Feel free to skip it +upon first reading. + +You can supply an empty regexp constant (@samp{//}) in all places +where a regexp is expected. Is this useful? What does it match? + +It is useful. It matches the (invisible) empty string at the start +and end of a string of characters, as well as the empty string +between characters. This is best illustrated with the @code{gsub()} +function, which makes global substitutions in a string +(@pxref{String Functions}). Normal usage of @code{gsub()} is like +so: + +@example +$ @kbd{awk '} +> @kbd{BEGIN @{} +> @kbd{ x = "ABC_CBA"} +> @kbd{ gsub(/B/, "bb", x)} +> @kbd{ print x} +> @kbd{@}'} +@print{} AbbC_CbbA +@end example + +We can use @code{gsub()} to see where the empty strings +are that match the empty regexp: + +@example +$ @kbd{awk '} +> @kbd{BEGIN @{} +> @kbd{ x = "ABC"} +> @kbd{ gsub(//, "x", x)} +> @kbd{ print x} +> @kbd{@}'} +@print{} xAxBxCx +@end example +@end cartouche +@end ifnotdocbook + @node Interval Expressions @subsection Some Notes On Interval Expressions diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 6ad9d6e0..a8c1cf86 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -5747,6 +5747,46 @@ regexp that precedes them. For example, @code{/+/} matches a literal plus sign. However, many other versions of @command{awk} treat such a usage as a syntax error. +@sidebar What About The Empty Regexp? +@cindex empty regexps +@cindex regexps, empty +We describe here an advanced regexp usage. Feel free to skip it +upon first reading. + +You can supply an empty regexp constant (@samp{//}) in all places +where a regexp is expected. Is this useful? What does it match? + +It is useful. It matches the (invisible) empty string at the start +and end of a string of characters, as well as the empty string +between characters. This is best illustrated with the @code{gsub()} +function, which makes global substitutions in a string +(@pxref{String Functions}). Normal usage of @code{gsub()} is like +so: + +@example +$ @kbd{awk '} +> @kbd{BEGIN @{} +> @kbd{ x = "ABC_CBA"} +> @kbd{ gsub(/B/, "bb", x)} +> @kbd{ print x} +> @kbd{@}'} +@print{} AbbC_CbbA +@end example + +We can use @code{gsub()} to see where the empty strings +are that match the empty regexp: + +@example +$ @kbd{awk '} +> @kbd{BEGIN @{} +> @kbd{ x = "ABC"} +> @kbd{ gsub(//, "x", x)} +> @kbd{ print x} +> @kbd{@}'} +@print{} xAxBxCx +@end example +@end sidebar + @node Interval Expressions @subsection Some Notes On Interval Expressions |