<?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[Help with regex and find&#x2F;replace]]></title><description><![CDATA[<p dir="auto">Hi everyone 😊<br />
I’m trying unsuccessfully for a regex to try and replace this code.</p>
<p dir="auto">Find<br />
[data=‘user1’ pid=‘123456’ dateline=‘1546943844’]message[/data]</p>
<p dir="auto">Replace with<br />
[data author=user1 link=msg=123456 date=1546943844]message[/data]</p>
<p dir="auto">user1, 123456, 1546943844 and message are variable data.</p>
<p dir="auto">Is it possible to do it with regex or am I going crazy for nothing?</p>
<p dir="auto">Many thanks.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/16916/help-with-regex-and-find-replace</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 13:58:16 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/16916.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 10 Jan 2019 20:37:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Help with regex and find&#x2F;replace on Fri, 11 Jan 2019 10:45:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@PeterJones</a> said:</p>
<blockquote>
<p dir="auto">Welcom, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/14172">@Massimo</a>,</p>
<p dir="auto">I am assuming those are really normal-quotes, not smart-quotes.  Please see <a href="https://notepad-plus-plus.org/community/topic/14262/how-to-markdown-code-on-this-forum/2" rel="nofollow ugc">this awesome thread</a> which explains how to use markdown to format your posts, so that the forum doesn’t change you important characters into smart characters.</p>
</blockquote>
<p dir="auto">Hi Peter, thanks for your help!</p>
<p dir="auto">Are smart-quotes that in dabase are saved as</p>
<pre><code>&amp;#39;
</code></pre>
<p dir="auto">This worked perfectly!</p>
<p dir="auto">Find</p>
<pre><code>data=&amp;#39;([^']*)&amp;#39; pid=&amp;#39;([^']*)&amp;#39; dateline=&amp;#39;([^']*)&amp;#39;
</code></pre>
<p dir="auto">Replace with</p>
<pre><code>data=$1 link=msg=$2 date=$3
</code></pre>
<p dir="auto">Thanks again 😉</p>
]]></description><link>https://community.notepad-plus-plus.org/post/38334</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/38334</guid><dc:creator><![CDATA[Massimo]]></dc:creator><pubDate>Fri, 11 Jan 2019 10:45:59 GMT</pubDate></item><item><title><![CDATA[Reply to Help with regex and find&#x2F;replace on Thu, 10 Jan 2019 20:58:05 GMT]]></title><description><![CDATA[<p dir="auto">Welcom, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/14172">@Massimo</a>,</p>
<p dir="auto">I am assuming those are really normal-quotes, not smart-quotes.  Please see <a href="https://notepad-plus-plus.org/community/topic/14262/how-to-markdown-code-on-this-forum/2" rel="nofollow ugc">this awesome thread</a> which explains how to use markdown to format your posts, so that the forum doesn’t change you important characters into smart characters.</p>
<p dir="auto">what are the rules for each of the “variable data” contents?  something like “data can be any alphanumeric sequence”, “pid and dateline must be numeric” – or “they can contain anything, as long as it’s not a quotemark”</p>
<p dir="auto">Did you want quotes around the values in the replace, or not?  There was a red flag when I saw <code>link=msg=123456</code>…</p>
<p dir="auto">Assuming normal quotes in source, no quotes in replace, and any non-quote allowed in the variable-data, I would do:</p>
<pre><code>[data='user1' pid='123456' dateline='1546943844']message[/data]
</code></pre>
<ul>
<li>
<p dir="auto">find = <code>data='([^']*)' pid='([^']*)' dateline='([^']*)'</code></p>
</li>
<li>
<p dir="auto">replace = <code>data=$1 link=msg=$2 date=$3</code></p>
</li>
<li>
<p dir="auto">mode = regular expression</p>
<p dir="auto">[data=user1 link=msg=123456 date=1546943844]message[/data]</p>
</li>
</ul>
<p dir="auto">If the order of the data/pid/dateline might change from row to row, or if you want to include lines that have <code>[data...]message[/data]</code> but exclude lines that have <code>[data...]different text[/data]</code> then you will have to give us a longer data set, with examples of lines that will and won’t be modified.  Please show the examples using Markdown, so we get the appropriate data, and don’t have to guess</p>
<p dir="auto">----<br />
boilerplate that I include in search-and-replace threads:</p>
<blockquote>
<p dir="auto">FYI: if you have further search-and-replace (regex) needs, study <a href="https://notepad-plus-plus.org/community/topic/15765/faq-desk-where-to-find-regex-documentation" rel="nofollow ugc">this FAQ</a> and the documentation it points to. Before asking a new regex question, understand that for future requests, many of us will expect you to show what data you have (exactly), what data you want (exactly), what regex you already tried (to show that you’re showing effort), why you thought that regex would work (to prove it wasn’t just something randomly typed), and what data you’re getting with an explanation of why that result is wrong. When you show that effort, you’ll see us bend over backward to get things working for you.  If you need help formatting the data so that the forum doesn’t mangle it (so that it shows “exactly”, as I said earlier), see <a href="https://notepad-plus-plus.org/community/topic/14262/how-to-markdown-code-on-this-forum/2" rel="nofollow ugc">this help-with-markdown post</a>, where <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/374">@Scott-Sumner</a> gives a great summary of how to use Markdown for this forum’s needs.<br />
Please note that for all “regex” queries – or queries where you want help “matching” or “marking” or “bookmarking”  a certain pattern, which amounts to the same thing – it is best if you are explicit about what needs to match, <em>and</em> what <em>shouldn’t</em> match, and have multiple examples of both in your example dataset.  Often, what <em>shouldn’t match</em> helps define the regular expression as much or more than what <em>should match</em>.</p>
</blockquote>
]]></description><link>https://community.notepad-plus-plus.org/post/38295</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/38295</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 10 Jan 2019 20:58:05 GMT</pubDate></item></channel></rss>