<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>replace on
A Scripter's Notes</title><link>https://scripter.co/categories/replace/</link><description>Recent content in replace
on A Scripter's Notes</description><language>en-us</language><managingEditor>kaushal.modi@gmail.com (Kaushal Modi)</managingEditor><webMaster>kaushal.modi@gmail.com (Kaushal Modi)</webMaster><lastBuildDate>Wed, 22 Apr 2026 08:24:58 -0400</lastBuildDate><generator>Hugo -- gohugo.io</generator><docs>https://validator.w3.org/feed/docs/rss2.html</docs><atom:link href="https://scripter.co/categories/replace/index.xml" rel="self" type="application/rss+xml"/><item><title>Search/replace groups using sed</title><link>https://scripter.co/search-replace-groups-using-sed/</link><description>&lt;p>This is the most common way of my sed usage:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="nb">echo&lt;/span> Good morning &lt;span class="p">|&lt;/span> sed &lt;span class="s1">&amp;#39;s/\(.*\s\+\).*/\1evening/g&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Here are brief notes on that ..&lt;/p>
&lt;p>The above script changes &lt;code>Good morning&lt;/code> to &lt;code>Good evening&lt;/code>.
Note that the following characters needed the escape character &lt;code>\&lt;/code>:&lt;/p>
&lt;ul>
&lt;li>Brackets to create regex groups: &lt;code>\(&lt;/code> &lt;code>\)&lt;/code>&lt;/li>
&lt;li>Plus sign to match one or more times: &lt;code>\+&lt;/code>&lt;/li>
&lt;li>Note that the &lt;code>.&lt;/code> and &lt;code>*&lt;/code> characters don&amp;rsquo;t need escaping.&lt;/li>
&lt;/ul></description><category domain="https://scripter.co/categories/sed">sed</category><category domain="https://scripter.co/categories/regex">regex</category><category domain="https://scripter.co/categories/escape">escape</category><category domain="https://scripter.co/categories/search">search</category><category domain="https://scripter.co/categories/replace">replace</category><guid>https://scripter.co/search-replace-groups-using-sed/</guid><pubDate>Wed, 16 Apr 2014 14:16:42 -0400</pubDate></item><item><title>How to change upper case to lower via search/replace?</title><link>https://scripter.co/how-to-change-upper-case-to-lower-via-search-replace/</link><description>&lt;p>This posts explain how the emacs in-built &lt;code>query-replace-regexp&lt;/code>
command can be used to convert upper-cased strings to lower case.&lt;/p>
&lt;ul>
&lt;li>Do &lt;code>M-x query-replace-regexp&lt;/code> or use the default binding &lt;code>C-M-%&lt;/code> to
activate the regular expression search/replace.&lt;/li>
&lt;li>Enter the regexp for the strings to be replaced in the *Query regexp:&amp;quot;
field. For instance, if I want to convert &lt;code>I_data&lt;/code> and &lt;code>Q_data&lt;/code> to
&lt;code>i_data&lt;/code> and &lt;code>q_data&lt;/code> respectively, then my search regular expression
will be &lt;code>\([IQ]\)_data&lt;/code>.&lt;/li>
&lt;li>It is important to use the &lt;strong>escaped&lt;/strong> grouping brackets &lt;code>\(&lt;/code> and &lt;code>\)&lt;/code>
to wrap an expression that you want to upcase or downcase.&lt;/li>
&lt;li>In the next &lt;em>Query replace:&lt;/em> prompt, the expression will be
&lt;code>\,(downcase \1)_data&lt;/code>&lt;sup id="fnref:1">&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref">1&lt;/a>&lt;/sup>.&lt;/li>
&lt;/ul>
&lt;div class="footnotes" role="doc-endnotes">
&lt;hr>
&lt;ol>
&lt;li id="fn:1">
&lt;p>Use &lt;code>\,(upcase \REGEXGROUPNUMBER)&lt;/code> to convert to upper case instead.&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;/ol>
&lt;/div></description><category domain="https://scripter.co/categories/emacs">emacs</category><category domain="https://scripter.co/categories/regex">regex</category><category domain="https://scripter.co/categories/replace">replace</category><guid>https://scripter.co/how-to-change-upper-case-to-lower-via-search-replace/</guid><pubDate>Fri, 14 Mar 2014 09:46:58 -0400</pubDate></item></channel></rss>