<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Regular Expression with find a pattern and replace]]></title><description><![CDATA[<p dir="auto">Looking to find a block where starts with <strong>CREATE procedure</strong> and ends with <strong>) as</strong><br />
and In replace add additional line select @site = ‘Site’ at the end.</p>
<p dir="auto">CREATE PROCEDURE [dbo].[ki_APSGetTopLevelDemand_BKUP]<br />
(<br />
@IpRefType AS VARCHAR(100),<br />
@IpRefNum AS VARCHAR(100),<br />
@IpRefLine AS INT<br />
)<br />
AS</p>
<p dir="auto">Its not case sensitive.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/22144/regular-expression-with-find-a-pattern-and-replace</link><generator>RSS for Node</generator><lastBuildDate>Thu, 23 Apr 2026 02:23:46 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/22144.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 15 Nov 2021 20:16:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Regular Expression with find a pattern and replace on Thu, 18 Nov 2021 17:47:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/22667">@shashi-bhosale</a> ,</p>
<p dir="auto">When I read your post earlier this week, I had hoped someone else would chime in, because I was pretty busy.  Sorry no one else had a chance to reply before I finally found a spare moment to go back through unanswered questions.</p>
<p dir="auto">If I have interpreted your request, then if I start with</p>
<pre><code>CREATE PROCEDURE [dbo].[ki_APSGetTopLevelDemand_BKUP]
(
@IpRefType AS VARCHAR(100),
@IpRefNum AS VARCHAR(100),
@IpRefLine AS INT
)
AS

blah blah blah

CREATE PROCEDURE [dbo].[ki_APSGetTopLevelDemand_BKUP]
(
@IpRefType AS VARCHAR(100),
@IpRefNum AS VARCHAR(100),
@IpRefLine AS INT
)
AS

</code></pre>
<p dir="auto">and use</p>
<ul>
<li>FIND = <code>(\)\s*AS)</code></li>
<li>REPLACE = <code>$0\r\n@site = 'Site'</code></li>
<li>SEARCH MODE = regular expression</li>
</ul>
<p dir="auto">After doing the two replacements (or a REPLACE ALL), I get what I think you want:</p>
<pre><code>CREATE PROCEDURE [dbo].[ki_APSGetTopLevelDemand_BKUP]
(
@IpRefType AS VARCHAR(100),
@IpRefNum AS VARCHAR(100),
@IpRefLine AS INT
)
AS
@site = 'Site'

blah blah blah

CREATE PROCEDURE [dbo].[ki_APSGetTopLevelDemand_BKUP]
(
@IpRefType AS VARCHAR(100),
@IpRefNum AS VARCHAR(100),
@IpRefLine AS INT
)
AS
@site = 'Site'
</code></pre>
<p dir="auto">If you want to know more about the individual tokens in my search and replace, look at the official search/regex section of the usermanual, linked below, for the following concepts</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>token</th>
<th>see usermanual section about</th>
</tr>
</thead>
<tbody>
<tr>
<td>parentheses</td>
<td>capture groups</td>
</tr>
<tr>
<td><code>\s</code></td>
<td>character escape sequences</td>
</tr>
<tr>
<td><code>*</code></td>
<td>multiplying operators</td>
</tr>
<tr>
<td><code>\r\n</code></td>
<td>control characters (note that they are case sensitive)</td>
</tr>
</tbody>
</table>
<p dir="auto">----</p>
<h3>Useful References</h3>
<ul>
<li><a href="https://community.notepad-plus-plus.org/topic/21965/please-read-before-posting">Please Read Before Posting</a></li>
<li><a href="https://community.notepad-plus-plus.org/topic/22022/template-for-search-replace-questions">Template for Search/Replace Questions</a></li>
<li><a href="https://community.notepad-plus-plus.org/topic/15765/faq-desk-where-to-find-regular-expressions-regex-documentation">FAQ: Where to find regular expressions (regex) documentation</a></li>
<li><a href="https://npp-user-manual.org/docs/searching/#regular-expressions" rel="nofollow ugc">Notepad++ Online User Manual: Searching/Regex</a></li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/71421</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/71421</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 18 Nov 2021 17:47:11 GMT</pubDate></item></channel></rss>