<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-us"><generator uri="https://gohugo.io/" version="0.101.0">Hugo</generator><title type="html">replace on A Scripter's Notes</title><subtitle type="html">Emacs, scripting and anything text oriented.</subtitle><link href="https://scripter.co/categories/replace/" rel="alternate" type="text/html" title="HTML"/><link href="https://scripter.co/categories/replace/index.xml" rel="alternate" type="application/rss+xml" title="RSS"/><link href="https://scripter.co/categories/replace/atom.xml" rel="self" type="application/atom+xml" title="Atom"/><link href="https://scripter.co/categories/replace/jf2feed.json" rel="alternate" type="application/jf2feed+json" title="jf2feed"/><updated>2026-04-22T08:24:57-04:00</updated><author><name>Kaushal Modi</name><email>kaushal.modi@gmail.com</email></author><id>https://scripter.co/categories/replace/</id><entry><title type="html">Search/replace groups using sed</title><link href="https://scripter.co/search-replace-groups-using-sed/?utm_source=atom_feed" rel="alternate" type="text/html"/><id>https://scripter.co/search-replace-groups-using-sed/</id><published>2014-04-16T14:16:42-04:00</published><updated>2014-04-16T14:16:42-04:00</updated><content type="html"><![CDATA[<p>This is the most common way of my sed usage:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">echo</span> Good morning <span class="p">|</span> sed <span class="s1">&#39;s/\(.*\s\+\).*/\1evening/g&#39;</span>
</span></span></code></pre></div><p>Here are brief notes on that ..</p>
<p>The above script changes <code>Good morning</code> to <code>Good evening</code>.
Note that the following characters needed the escape character <code>\</code>:</p>
<ul>
<li>Brackets to create regex groups: <code>\(</code> <code>\)</code></li>
<li>Plus sign to match one or more times: <code>\+</code></li>
<li>Note that the <code>.</code> and <code>*</code> characters don&rsquo;t need escaping.</li>
</ul>]]></content><category scheme="https://scripter.co/categories/sed" term="sed" label="sed"/><category scheme="https://scripter.co/categories/regex" term="regex" label="regex"/><category scheme="https://scripter.co/categories/escape" term="escape" label="escape"/><category scheme="https://scripter.co/categories/search" term="search" label="search"/><category scheme="https://scripter.co/categories/replace" term="replace" label="replace"/></entry><entry><title type="html">How to change upper case to lower via search/replace?</title><link href="https://scripter.co/how-to-change-upper-case-to-lower-via-search-replace/?utm_source=atom_feed" rel="alternate" type="text/html"/><id>https://scripter.co/how-to-change-upper-case-to-lower-via-search-replace/</id><published>2014-03-14T09:46:58-04:00</published><updated>2014-03-14T09:46:58-04:00</updated><content type="html"><![CDATA[<p>This posts explain how the emacs in-built <code>query-replace-regexp</code>
command can be used to convert upper-cased strings to lower case.</p>
<ul>
<li>Do <code>M-x query-replace-regexp</code> or use the default binding <code>C-M-%</code> to
activate the regular expression search/replace.</li>
<li>Enter the regexp for the strings to be replaced in the *Query regexp:&quot;
field. For instance, if I want to convert <code>I_data</code> and <code>Q_data</code> to
<code>i_data</code> and <code>q_data</code> respectively, then my search regular expression
will be <code>\([IQ]\)_data</code>.</li>
<li>It is important to use the <strong>escaped</strong> grouping brackets <code>\(</code> and <code>\)</code>
to wrap an expression that you want to upcase or downcase.</li>
<li>In the next <em>Query replace:</em> prompt, the expression will be
<code>\,(downcase \1)_data</code><sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>.</li>
</ul>
<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p>Use <code>\,(upcase \REGEXGROUPNUMBER)</code> to convert to upper case instead.&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</div>]]></content><category scheme="https://scripter.co/categories/emacs" term="emacs" label="emacs"/><category scheme="https://scripter.co/categories/regex" term="regex" label="regex"/><category scheme="https://scripter.co/categories/replace" term="replace" label="replace"/></entry></feed>