|
5 | 5 | <link href="https://learnbyexample.github.io/atom.xml" rel="self" type="application/atom+xml"/>
|
6 | 6 | <link href="https://learnbyexample.github.io"/>
|
7 | 7 | <generator uri="https://www.getzola.org/">Zola</generator>
|
8 |
| - <updated>2023-05-30T00:00:00+00:00</updated> |
| 8 | + <updated>2023-06-05T00:00:00+00:00</updated> |
9 | 9 | <id>https://learnbyexample.github.io/atom.xml</id>
|
| 10 | + <entry xml:lang="en"> |
| 11 | + <title>Vim tip 27: regexp anchors</title> |
| 12 | + <published>2023-06-05T00:00:00+00:00</published> |
| 13 | + <updated>2023-06-05T00:00:00+00:00</updated> |
| 14 | + <link rel="alternate" href="https://learnbyexample.github.io/tips/vim-tip-27/" type="text/html"/> |
| 15 | + <id>https://learnbyexample.github.io/tips/vim-tip-27/</id> |
| 16 | + <content type="html"><p>By default, regexp matches anywhere in the text. You can use line and word anchors to specify additional restrictions regarding the position of matches. These restrictions are made possible by assigning special meaning to certain characters (<strong>metacharacters</strong>) and escape sequences.</p> |
| 17 | +<ul> |
| 18 | +<li><code>^</code> restricts the match to the start-of-line |
| 19 | +<ul> |
| 20 | +<li><code>^This</code> matches <code>This is a sample</code> but not <code>Do This</code></li> |
| 21 | +</ul> |
| 22 | +</li> |
| 23 | +<li><code>$</code> restricts the match to the end-of-line |
| 24 | +<ul> |
| 25 | +<li><code>)$</code> matches <code>apple (5)</code> but not <code>def greeting():</code></li> |
| 26 | +</ul> |
| 27 | +</li> |
| 28 | +<li><code>^$</code> match empty line</li> |
| 29 | +<li><code>\&lt;pattern</code> restricts the match to the start of a word |
| 30 | +<ul> |
| 31 | +<li>word characters include alphabets, digits and underscore</li> |
| 32 | +<li><code>\&lt;his</code> matches <code>his</code> or <code>to-his</code> or <code>history</code> but not <code>this</code> or <code>_hist</code></li> |
| 33 | +</ul> |
| 34 | +</li> |
| 35 | +<li><code>pattern\&gt;</code> restricts the match to the end of a word |
| 36 | +<ul> |
| 37 | +<li><code>his\&gt;</code> matches <code>his</code> or <code>to-his</code> or <code>this</code> but not <code>history</code> or <code>_hist</code></li> |
| 38 | +</ul> |
| 39 | +</li> |
| 40 | +<li><code>\&lt;pattern\&gt;</code> restricts the match between start of a word and end of a word |
| 41 | +<ul> |
| 42 | +<li><code>\&lt;his\&gt;</code> matches <code>his</code> or <code>to-his</code> but not <code>this</code> or <code>history</code> or <code>_hist</code></li> |
| 43 | +</ul> |
| 44 | +</li> |
| 45 | +</ul> |
| 46 | +<p><img src="/images/info.svg" alt="info" /> End-of-line can be <code>\r</code> (carriage return), <code>\n</code> (newline) or <code>\r\n</code> depending on your system and <code>fileformat</code> setting.</p> |
| 47 | +<p><img src="/images/info.svg" alt="info" /> See <a href="https://vimhelp.org/pattern.txt.html#pattern-atoms">:h pattern-atoms</a> for more details.</p> |
| 48 | +<p><strong>Video demo</strong>:</p> |
| 49 | +<p align="center"><iframe width="560" height="315" loading="lazy" src="https://www.youtube.com/embed/AJNWtpKA2zM" title="YouTube video player" frameborder="0" allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></p> |
| 50 | +<br> |
| 51 | +<p><img src="/images/info.svg" alt="info" /> See also my <a href="https://github.com/learnbyexample/vim_reference">Vim Reference Guide</a> and <a href="https://learnbyexample.github.io/curated_resources/vim.html">curated list of resources for Vim</a>.</p> |
| 52 | +</content> |
| 53 | + </entry> |
10 | 54 | <entry xml:lang="en">
|
11 | 55 | <title>CLI tip 28: substitute specific occurrence with GNU sed</title>
|
12 | 56 | <published>2023-05-30T00:00:00+00:00</published>
|
|
0 commit comments