<?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[How to: Convert Roman numerals to Arabic numbers ?]]></title><description><![CDATA[<p dir="auto">I have an Html document that sometimes uses Roman numerals<br />
and I want to Convert Roman numerals to Arabic numbers .<br />
How can I do this ?<br />
Thanks for your Help…</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/21611/how-to-convert-roman-numerals-to-arabic-numbers</link><generator>RSS for Node</generator><lastBuildDate>Tue, 13 Oct 2026 21:38:09 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/21611.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 05 Aug 2021 15:41:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to: Convert Roman numerals to Arabic numbers ? on Thu, 05 Aug 2021 17:50:32 GMT]]></title><description><![CDATA[<p dir="auto">Whoa!<br />
Thank you very much Peter .<br />
Here is the .html :<br />
[<a href="https://vmars.us/ShowMe/A.Little.Book-On-the-Christian-Life-John-Calvin-Direct-Edit.html" rel="nofollow ugc">https://vmars.us/ShowMe/A.Little.Book-On-the-Christian-Life-John-Calvin-Direct-Edit.html</a>](link url)<br />
…Vernon</p>
]]></description><link>https://community.notepad-plus-plus.org/post/68614</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/68614</guid><dc:creator><![CDATA[vmars vernon]]></dc:creator><pubDate>Thu, 05 Aug 2021 17:50:32 GMT</pubDate></item><item><title><![CDATA[Reply to How to: Convert Roman numerals to Arabic numbers ? on Thu, 05 Aug 2021 16:47:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vmars-vernon" aria-label="Profile: vmars-vernon">@<bdi>vmars-vernon</bdi></a> ,</p>
<p dir="auto">I got interested:</p>
<pre><code># encoding=utf-8
"""in response to https://community.notepad-plus-plus.org/topic/21611/

matches any "roman numeral", which I define as
* any "word" that's a combination of I, V, X, L, C, D, M (only upper case)
* except if it's a lone I at the beginning of a line,
  or a lone I after a . or ? or ! or ; or , or " and one or two spaces
"""
from Npp import *

def roman_to_int(s):
    """stolen from https://www.w3resource.com/python-exercises/class-exercises/python-class-exercise-2.php"""
    rom_val = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
    int_val = 0
    for i in range(len(s)):
        if i &gt; 0 and rom_val[s[i]] &gt; rom_val[s[i - 1]]:
            int_val += rom_val[s[i]] - 2 * rom_val[s[i - 1]]
        else:
            int_val += rom_val[s[i]]
    return int_val

def deromanize_match(m):
    return str(roman_to_int(m.group().rstrip()))

editor.beginUndoAction()
editor.rereplace(r'(?-is)(?!^\x20*I\x20)(?!(?&lt;=[.?!,;"]\x20)I\x20)(?!(?&lt;=[.?!,;"]\x20\x20)I\x20)\b[IVXLCDM]+\b', deromanize_match)
editor.endUndoAction()
</code></pre>
<p dir="auto">converts</p>
<pre><code>Convert MMMCMLXXXVI
Convert MDCLXVI
I say, I am not sure, but treat this line as pronouns
Don't edit using the vi editor, which won't match because it's lower case
Some sentence. I am still a sentence with a pronoun.
But this.  The I here is a roman numeral.
I say, II is surely roman.
</code></pre>
<p dir="auto">to</p>
<pre><code>Convert 3986
Convert 1666
I say, I am not sure, but treat this line as pronouns
Don't edit using the vi editor, which won't match because it's lower case
Some sentence. I am still a sentence with a pronoun.
But this.  The 1 here is a roman numeral.
I say, 2 is surely roman.
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/68613</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/68613</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 05 Aug 2021 16:47:10 GMT</pubDate></item><item><title><![CDATA[Reply to How to: Convert Roman numerals to Arabic numbers ? on Thu, 05 Aug 2021 15:59:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vmars-vernon" aria-label="Profile: vmars-vernon">@<bdi>vmars-vernon</bdi></a> ,</p>
<p dir="auto">Notepad++ doesn’t know roman numerals as distinct from any other character, and has no inherent meaning associated. Most of the roman-to-arabic conversions I know use math, and Notepad++ search/replace cannot do math.</p>
<p dir="auto">You would either have to find or write a plugin that could do it, or use a plugin like PythonScript and write a script that would do the conversion.</p>
<p dir="auto">When making the plugin or script, just make sure you think about edge cases like <code>&lt;blockquote&gt;I came, I saw, I conquered&lt;/blockquote&gt;</code> (which should <em>not</em> become <code>&lt;blockquote&gt;1 came, 1 saw, 1 conquered&lt;/blockquote&gt;)</code>, or <code>&lt;p&gt;Use Notepad++, not vi, if you're on Windows&lt;/p&gt;</code> (which should <em>not</em> become <code>&lt;p&gt;Use Notepad++, not 6, if you're on Windows&lt;/p&gt;</code>)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/68609</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/68609</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 05 Aug 2021 15:59:34 GMT</pubDate></item></channel></rss>