<?xml version="1.0" encoding="UTF-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0" xml:id="learn_regexPreFormed">
   <teiHeader>
      <fileDesc>
         <titleStmt>
            <title type="main">Pre-Formed Regular Expressions</title>
            <respStmt xml:id="odd_JENS1_wtm">
               <resp ref="resp:wtm">Technical Writer</resp>
               <persName ref="pers:JENS1">Janelle Jenstad</persName>
            </respStmt>
            <respStmt xml:id="odd_HOUL3_wtm">
               <resp ref="resp:wtm">Technical Writer</resp>
               <persName ref="pers:HOUL3">Navarra Houldin</persName>
            </respStmt>
            <respStmt xml:id="odd_GALL2_wtm">
               <resp ref="resp:wtm">Technical Writer</resp>
               <persName ref="pers:GALL2">Mahayla Galliford</persName>
            </respStmt>
            <respStmt xml:id="odd_VATC1_wtm">
               <resp ref="resp:wtm">Technical Writer</resp>
               <persName ref="pers:VATC1">Nicole Vatcher</persName>
            </respStmt>
            <respStmt xml:id="odd_ELHA1_wtm">
               <resp ref="resp:wtm">Technical Writer</resp>
               <persName ref="pers:ELHA1">Tracey El Hajj</persName>
            </respStmt>
            <respStmt xml:id="odd_GALL2_pfr">
               <resp ref="resp:pfr">Proofreader</resp>
               <persName ref="pers:GALL2">Mahayla Galliford</persName>
            </respStmt>
            <respStmt xml:id="odd_SEAL1_pfr">
               <resp ref="resp:pfr">Proofreader</resp>
               <persName ref="pers:SEAL1">Isabella Seales</persName>
            </respStmt>
            <respStmt>
               <resp ref="resp:pdr">Project Director</resp>
               <persName ref="pers:JENS1">Janelle Jenstad</persName>
            </respStmt>
            <respStmt>
               <resp ref="resp:man">Project Manager</resp>
               <persName ref="pers:GALL2">Mahayla Galliford</persName>
            </respStmt>
            <respStmt>
               <resp ref="resp:wtm">Training and Documentation Lead</resp>
               <persName ref="pers:HOUL3">Navarra Houldin</persName>
            </respStmt>
            <respStmt>
               <resp ref="resp:man">Assistant Project Manager</resp>
               <persName ref="pers:SEAB1">Samuel Seaberg</persName>
            </respStmt>
            <respStmt>
               <resp ref="resp:prg">Programmer</resp>
               <persName ref="pers:HOLM1">Martin Holmes</persName>
            </respStmt>
            <respStmt>
               <resp ref="resp:prg">Programmer</resp>
               <persName ref="pers:NOKH1">Illya Nokhrin</persName>
            </respStmt>
            <respStmt>
               <resp ref="resp:prg">Programmer</resp>
               <persName ref="pers:TAKE1">Joey Takeda</persName>
            </respStmt>
            <respStmt>
               <resp ref="resp:prg">Junior Programmer</resp>
               <persName ref="pers:ELHA1">Tracey El Hajj</persName>
            </respStmt>
            <sponsor ref="org:LEMD1"/>
            <funder>Social Sciences and Humanities Research Council of Canada</funder>
         </titleStmt>
         <editionStmt>
            <p>Released with Linked Early Modern Drama Online 1.0</p>
         </editionStmt>
         <publicationStmt>
            <publisher>University of Victoria on the Linked Early Modern Drama Online Platform</publisher>
            <availability>
               <licence from="2023-12-10" resp="pers:JENS1" corresp="anth:lemdo"/>
               <p>This file is licensed under a <ref target="https://creativecommons.org/licenses/by-nc-nd/4.0/">CC BY-NC_ND 4.0 license</ref>, which means that it is freely downloadable without permission under the following conditions: (1) credit must be given to the author and LEMDO in any subsequent use of the files and/or data; (2) the content cannot be adapted or repurposed (except in quotations for the purposes of academic review and citation); and (3) commercial uses are not permitted without the knowledge and consent of the editor and LEMDO. This license allows for pedagogical use of the documentation in the classroom.</p>
            </availability>
         </publicationStmt>
         <seriesStmt>
            <p>Linked Early Modern Drama Online</p>
         </seriesStmt>
         <sourceDesc>
            <p>TEI Customization created by <orgName ref="pers:HOLM1">Martin Holmes</orgName>, <orgName ref="pers:TAKE1">Joey Takeda</orgName>, and <orgName ref="pers:JENS1">Janelle Jenstad</orgName>; documentation written by members of the <orgName ref="org:LEMD1">LEMDO Team</orgName>
            </p>
         </sourceDesc>
      </fileDesc>
      <profileDesc>
         <textClass>
            <catRef scheme="tax:emdDocumentTypes" target="cat:ldtBornDigDocumentation"/>
            <catRef scheme="tax:emdDocumentTypes" target="cat:ldtBornDig"/>
         </textClass>
      </profileDesc>
      <tei:encodingDesc xmlns:tei="http://www.tei-c.org/ns/1.0">
         <p>Encoded in TEI P5 according to the LEMDO Customization and Encoding Guidelines</p>
         <editorialDecl>
            <p>n/a</p>
         </editorialDecl>
         <tei:constraintDecl scheme="schematron" queryBinding="xslt2">
            <sch:ns xmlns:sch="http://purl.oclc.org/dsdl/schematron"
                    prefix="tei"
                    uri="http://www.tei-c.org/ns/1.0"/>
            <sch:ns xmlns:sch="http://purl.oclc.org/dsdl/schematron"
                    prefix="xs"
                    uri="http://www.w3.org/2001/XMLSchema"/>
            <sch:ns xmlns:sch="http://purl.oclc.org/dsdl/schematron"
                    prefix="rng"
                    uri="http://relaxng.org/ns/structure/1.0"/>
            <sch:ns xmlns:sch="http://purl.oclc.org/dsdl/schematron"
                    prefix="rna"
                    uri="http://relaxng.org/ns/compatibility/annotations/1.0"/>
            <sch:ns xmlns:sch="http://purl.oclc.org/dsdl/schematron"
                    prefix="sch"
                    uri="http://purl.oclc.org/dsdl/schematron"/>
            <sch:ns xmlns:sch="http://purl.oclc.org/dsdl/schematron"
                    prefix="sch1x"
                    uri="http://www.ascc.net/xml/schematron"/>
         </tei:constraintDecl>
      </tei:encodingDesc>
      <revisionDesc status="prgGenerated">
         <change who="pers:HOLM1" when="2026-09-10">Automatically generated this file by 
                        extracting its content from lemdo.lite.odd.</change>
      </revisionDesc>
   </teiHeader>
   <text>
      <body>
         <div ana="audRemediator"><!-- JENS1 wrote the explanations; ELHA1 and HOUL3 wrote the regular expressions; VATC1 added them to this file. JENS1 and HOUL3 added regular expressions on an ongoing basis. -->
            <div xmlns:lemdo="http://hcmc.uvic.ca/lemdo/ns"
                 xmlns:sch="http://purl.oclc.org/dsdl/schematron"
                 xmlns:teix="http://www.tei-c.org/ns/Examples"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xml:id="learn_regexPreFormed_prior">
               <head>Prior Reading</head>
               <list rend="bulleted">
                  <item>
                     <title level="a"><ref target="doc:learn_regex">Introduction to Regular Expressions</ref></title>
                  </item>
               </list>
            </div>
            <div xmlns:lemdo="http://hcmc.uvic.ca/lemdo/ns"
                 xmlns:sch="http://purl.oclc.org/dsdl/schematron"
                 xmlns:teix="http://www.tei-c.org/ns/Examples"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xml:id="learn_regexPreFormed_allEditionComponents">
               <head>Regex for All Edition Components</head>
               <p>The regular expressions in this section are useful in multiple edition components (e.g., you may use them in annotations and critical paratexts).</p>
               <table>
                  <row role="label">
                     <cell>Rationale</cell>
                     <cell>Find</cell>
                     <cell>Replace With</cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_replaceQ">
                     <cell>Replaces quotation marks with <ref target="doc:lemdo_spec_q"><gi>q</gi></ref> in converted files.</cell>
                     <cell>
                        <code>"([\w][^"]+)"(([\W])|($))</code> (Note: constrain to <code>text()</code> in the XPath context)</cell>
                     <cell>
                        <code>&lt;q&gt;$1&lt;/q&gt;$2</code>
                     </cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_replaceHyphen">
                     <cell>LEMDO uses en dashes in date and number ranges. We frequently receive files from editors that contain hyphens. This converts such hyphens to en dashes (without converting the hyphens that occur in the dates that are the values of attributes).</cell>
                     <cell>
                        <code>(\d+)-(\d+)</code> (Note: constrain to <code>text()</code> in the XPath context)</cell>
                     <cell>
                        <code>$1–$2</code>
                     </cell>
                  </row>
               </table>
            </div>
            <div xmlns:lemdo="http://hcmc.uvic.ca/lemdo/ns"
                 xmlns:sch="http://purl.oclc.org/dsdl/schematron"
                 xmlns:teix="http://www.tei-c.org/ns/Examples"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xml:id="learn_regexPreFormed_semiDip">
               <head>Regex for Semi-Diplomatic Transcriptions</head>
               <p>The regular expressions in this section are used in semi-diplomatic transcriptions that were converted from IML.</p>
               <table>
                  <row role="label">
                     <cell>Rationale</cell>
                     <cell>Find</cell>
                     <cell>Replace With</cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_removeExtraLb">
                     <cell>When you are working with IML-TEI converted texts, you may come across a lot of situations where an <ref target="doc:lemdo_spec_lb"><gi>lb</gi></ref> element appears right inside the <ref target="doc:lemdo_spec_ab"><gi>ab</gi></ref> of a speech, instead of before the <ref target="doc:lemdo_spec_sp"><gi>sp</gi></ref> tag. This removes those unwanted <ref target="doc:lemdo_spec_lb"><gi>lb</gi></ref> elements. Note: we recommend running this regex before adding renditions or making other changes to the file.</cell>
                     <cell>
                        <code>(&lt;sp&gt;\s+&lt;speaker&gt;.+?&lt;/speaker&gt;\s*&lt;ab&gt;\s*)(&lt;lb/&gt;)</code> (Note: make sure you check <quote>Dot matches all</quote>)</cell>
                     <cell>
                        <code>$2$1</code>
                     </cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_removeEditorialLineNumber">
                     <cell>This removes <ref target="doc:lemdo_spec_lb"><gi>lb</gi></ref> elements with <att>n</att> giving editorial line numbers.</cell>
                     <cell>
                        <code>&lt;lb\s+n="\d*\.*\d*"/&gt;</code>
                     </cell>
                     <cell>Leave empty</cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_removeOldFacs">
                     <cell>When you convert a file from TCP or IML to TEI, there will likely be old facsimile links in the <ref target="doc:lemdo_spec_pb"><gi>pb</gi></ref> element. This removes old facsimile links.</cell>
                     <cell>
                        <code>(&lt;pb)\sfacs=".+?"(/&gt;)</code>
                     </cell>
                     <cell>
                        <code>$1$2</code>
                     </cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_correctElementOrderSemiDip">
                     <cell>You may come across instances of the <ref target="doc:lemdo_spec_lb"><gi>lb</gi></ref> element appearing after <ref target="doc:lemdo_spec_sp"><gi>sp</gi></ref> rather than before it. This corrects order of elements.</cell>
                     <cell>
                        <code>(&lt;sp&gt;\s+)(&lt;lb/&gt;\s*)(&lt;speaker&gt;.+?&lt;/speaker&gt;)</code>
                     </cell>
                     <cell>
                        <code>$2$1$3</code>
                     </cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_standardizeAttributeOrderFW">
                     <cell>Standardizes attribute order on forme works. Note: this regex should be run before running any other regex on forme works.</cell>
                     <cell>
                        <code>&lt;fw(\srendition="(\s*\w+:\w+)+")(\stype="\w+")</code>
                        <note type="editorial">Explanation of find regex: this regex has three backreference groups: <list rend="numbered">
                              <item>
                                 <code>(\srendition="(\s*\w+:\w+)+")</code>: contains the <att>rendition</att> attribute and its value(s)</item>
                              <item>
                                 <code>(\s*\w+:\w+)+</code>: accounts for one or more values on the <att>rendition</att> attribute (note that format for <att>rendition</att> values is <val>rnd:[value]</val>)</item>
                              <item>
                                 <code>(\stype="\w+")</code>: contains the <att>type</att> attribute and its value</item>
                           </list>
                        </note>
                     </cell>
                     <cell>
                        <code>&lt;fw$3$1</code>
                        <note type="editorial">Explanation of replace regex: by putting $3 before $1 in the replace, this regex places the <att>type</att> attribute before the <att>rendition</att> attribute, which will format the <ref target="doc:lemdo_spec_fw"><gi>fw</gi></ref> elements correctly for other regex.</note>
                     </cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_removeCentreSig">
                     <cell>LEMDO’s default styling is to centre signature numbers. This removes unnecessary <att>rendition</att> attributes that only have the value <val>rnd:centre</val> from signature numbers.</cell>
                     <cell>
                        <code>(&lt;fw type="sig")\srendition="rnd:centre"</code>
                     </cell>
                     <cell>
                        <code>$1</code>
                     </cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_removeRightCatch">
                     <cell>LEMDO’s default styling is to align catch words to the right. This removes unnecessary <att>rendition</att> attributes that only have the value <val>rnd:right</val> from catch words.</cell>
                     <cell>
                        <code>(&lt;fw type="catch")\srendition="rnd:right"</code>
                     </cell>
                     <cell>
                        <code>$1</code>
                     </cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_removeSigSpace">
                     <cell>Removes unnecessary space from between the letter and number of signature marks</cell>
                     <cell>
                        <code>(&lt;fw type="sig"&gt;[a-zA-Z]+)\s(\d&lt;/fw&gt;)</code>
                        <note type="editorial">Explanation of find regex: this find has two backreference groups that are kept in the conversion: <list rend="numbered">
                              <item>
                                 <code>(&lt;fw type="sig"&gt;[a-zA-Z]+)</code>: contains the opening <ref target="doc:lemdo_spec_fw"><gi>fw</gi></ref> tag, all of the attributes on it, and the letter of the signature mark.</item>
                              <item>
                                 <code>(\d&lt;/fw&gt;)</code>: contains the number of the signature mark and the closing <tag>/fw</tag> tag.</item>
                           </list>
                           <list rend="bulleted">
                              <item>
                                 <code>&lt;fw type="sig"&gt; … &lt;/fw&gt;</code>: constrains the search to text encoded as signature marks.</item>
                              <item>
                                 <code>[a-zA-Z]+</code>: indicates the letter or letters in the signature mark. They may be capital or lower case letters, and there will be at least one (there may be more than one in long books with lots of gatherings).</item>
                              <item>
                                 <code>\s</code>: indicates the space between the letter and number. This will be removed in the conversion.</item>
                              <item>
                                 <code>\d</code>: indicates the number in the signature mark.</item>
                           </list>
                        </note>
                     </cell>
                     <cell>
                        <code>$1$2</code>
                        <note type="editorial">Explanation of replace regex: <list rend="bulleted">
                              <item>
                                 <code>$1</code>: Keeps the first backreference group during the conversion process.</item>
                              <item>
                                 <code>$2</code>: Keeps the second backreference group during the conversion process.</item>
                           </list> By excluding the <code>\s</code> from the replace, we eliminate the unwanted space.</note>
                     </cell>
                  </row>
                  <row role="data"
                       xml:id="learn_regexPreFormed_removeItalicCentreRunningTitle">
                     <cell>Removes italic and centre tagging from running titles. Note: after running this, always also run the <ref target="#learn_regexPreFormed_removeEmptyRendition">regex to remove empty <att>rendition</att> attributes</ref>.</cell>
                     <cell>
                        <code>(&lt;fw\stype="runningTitle"\srendition=")((\s*rnd:centre)|(\s*rnd:italic)|(\s*(rnd:\w+)))*"</code>
                     </cell>
                     <cell>
                        <code>$1$6"</code>
                     </cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_removeEmptyRendition">
                     <cell>Removes empty <att>rendition</att> attributes. Note: run this after using regex to remove values from <att>rendition</att> attributes.</cell>
                     <cell>
                        <code>\srendition=""</code>
                     </cell>
                     <cell>Leave empty</cell>
                  </row>
                  <row role="data"
                       xml:id="learn_regexPreFormed_removeItalicCentreHiOnRendition">
                     <cell>Removes italic and centre tagging on <ref target="doc:lemdo_spec_hi"><gi>hi</gi></ref> elements in running titles. Note: after running this, always also run the <ref target="#learn_regexPreFormed_removeEmptyHi">regex to remove empty <gi>hi</gi> elements</ref>.</cell>
                     <cell>
                        <code>(&lt;hi\srendition=")((\s*rnd:centre)|(\s*rnd:italic)|(\s*(rnd:\w+)))*"</code> (Note: constrain to <code>//fw[contains(@type, 'runningTitle')]</code> in the XPath field)</cell>
                     <cell>
                        <code>$1$6</code>
                     </cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_removeEmptyHi">
                     <cell>Removes empty <ref target="doc:lemdo_spec_hi"><gi>hi</gi></ref> elements after getting rid of values. Note: run this after using regex to remove values from <att>rendition</att> attributes on the <ref target="doc:lemdo_spec_hi"><gi>hi</gi></ref> element.</cell>
                     <cell>
                        <code>&lt;hi\srendition=""&gt;(.+?)&lt;\hi&gt;</code>
                     </cell>
                     <cell>
                        <code>$1</code>
                     </cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_removeItalicSpeaker">
                     <cell>Removes italic tagging on <ref target="doc:lemdo_spec_speaker"><gi>speaker</gi></ref> elements. Note: after running this, always also run the <ref target="#learn_regexPreFormed_removeEmptyRendition">regex to remove empty <att>rendition</att> attributes</ref>.</cell>
                     <cell>
                        <code>(&lt;speaker\srendition=")((\s*rnd:italic)|(\s*(\w+:\w+)))*"</code>
                     </cell>
                     <cell>
                        <code>$1$5"</code>
                     </cell>
                  </row>
                  <row role="data"
                       xml:id="learn_regexPreFormed_removeItalicAddNormalHiInSpeechPrefix">
                     <cell>Removes italic tagging on <ref target="doc:lemdo_spec_hi"><gi>hi</gi></ref> elements in speech prefixes and adds <ref target="doc:lemdo_spec_hi"><gi>hi</gi></ref> elements with <val>rnd:normal</val> around characters in roman type. Note: after running this, always also run the <ref target="#learn_regexPreFormed_removeEmptyHi">regex to remove empty <gi>hi</gi> elements</ref> and the <ref target="#learn_regexPreFormed_removeHiEmptyTextNode">regex to remove <gi>hi</gi> elements with empty text nodes</ref>.</cell>
                     <cell>
                        <code>(&lt;speaker&gt;)(.+?)*(&lt;hi\srendition=")((\s*rnd:italic)|(\s*(\w+:\w+)))*"&gt;(.+?)*(&lt;/speaker&gt;)</code>
                     </cell>
                     <cell>
                        <code>$1&lt;hi rendition="rnd:normal"&gt;$2&lt;/hi&gt;$3&lt;hi rendition="rnd:normal"&gt;$4&lt;/hi&gt;$5</code>
                     </cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_removeHiEmptyTextNode">
                     <cell>Removes <ref target="doc:lemdo_spec_hi"><gi>hi</gi></ref> element with empty text nodes.</cell>
                     <cell>
                        <code>&lt;hi\srendition=".+?"&gt;&lt;/hi&gt;</code>
                     </cell>
                     <cell>Leave empty</cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_standardizeAttributesStage">
                     <cell>Standardizes the order of attributes on the <ref target="doc:lemdo_spec_stage"><gi>stage</gi></ref> element. Note: run this regex before running any other regex on stage directions.</cell>
                     <cell>
                        <code>(&lt;stage)(\srendition="(\s*(\w+:\w+))+")(\stype="(\s*\w+)+")</code>
                     </cell>
                     <cell>
                        <code>$1$5$2</code>
                     </cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_removeItalicStage">
                     <cell>Removes italic tagging on <ref target="doc:lemdo_spec_stage"><gi>stage</gi></ref> elements. Note: after running this, always also run the <ref target="#learn_regexPreFormed_removeEmptyRendition">regex to remove empty <att>rendition</att> attributes</ref>.</cell>
                     <cell>
                        <code>(&lt;hi\srendition=")((\s*rnd:italic)|(\s*(rnd:\w+)))*"</code> (Note: constrain to <code>//stage</code> in the XPath field)</cell>
                     <cell>
                        <code>$1$5</code>
                     </cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_removeItalicHiInStage">
                     <cell>Removes italic tagging using the <ref target="doc:lemdo_spec_hi"><gi>hi</gi></ref> element in stage directions. Note: after running this, always also run the <ref target="#learn_regexPreFormed_removeEmptyHi">regex to remove empty <gi>hi</gi> elements</ref>.</cell>
                     <cell>
                        <code>(&lt;hi\srendition=")((\s*rnd:italic)|(\s*(rnd:\w+)))*"</code> (Note: constrain to <code>//stage</code> in the XPath field)</cell>
                     <cell>
                        <code>$1$5"</code>
                     </cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_removeWho">
                     <cell>Removes <att>who</att> attributes</cell>
                     <cell>
                        <code>&lt;sp who="#\w+"&gt;</code>
                        <note type="editorial">Explanation of find regex: <list rend="bulleted">
                              <item>
                                 <code>&lt;sp&gt;</code>: Constrains the search to <ref target="doc:lemdo_spec_sp"><gi>sp</gi></ref> elements.</item>
                              <item>
                                 <code>who="#\w+"</code>: Searches for the <att>who</att> attribute. This is the section that will be removed during the conversion. The hash character indicates that every value for the <att>who</att> attribute is prefixed by a hash character. <code>\w</code> indicates that the value following the hash character may consist of alphanumeric characters and underscores (word characters). The plus sign indicates that there will be one or more word character.</item>
                           </list>
                        </note>
                     </cell>
                     <cell>
                        <code>&lt;sp&gt;</code>
                     </cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_removeJustify">
                     <cell>Removes <val>rnd:justify</val>. Note: after running this, always also run the <ref target="#learn_regexPreFormed_removeEmptyHi">regex to remove empty <gi>hi</gi> elements</ref>.</cell>
                     <cell>
                        <code>\srendition="rnd:justify"</code>
                     </cell>
                     <cell>Leave empty</cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_removeSuppliedPage">
                     <cell>Removes supplied page numbers on the <att>n</att> attribute on the <ref target="doc:lemdo_spec_pb"><gi>pb</gi></ref> element</cell>
                     <cell>
                        <code>(&lt;pb\sn=")\d+;\s(\w+"/&gt;)</code>
                     </cell>
                     <cell>
                        <code>$1$2</code>
                     </cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_standardizeAttributeOrderLb">
                     <cell>The XSLT conversion to programmatically number lines in semi-diplomatic transcriptions puts the <att>n</att> attribute before the <att>type</att> attribute. While this is valid XML, LEMDO opts for the <att>type</att> attribute to appear before the <att>n</att> attribute. Consistency ensures easy searchability across our repository. This regex reorders the attributes so that they are consistent.</cell>
                     <cell>
                        <code>(&lt;lb)(\sn="\d+")(\stype="wln")(/&gt;)</code>
                     </cell>
                     <cell>
                        <code>$1$3$2$4</code>
                     </cell>
                  </row>
               </table>
            </div>
            <div xmlns:lemdo="http://hcmc.uvic.ca/lemdo/ns"
                 xmlns:sch="http://purl.oclc.org/dsdl/schematron"
                 xmlns:teix="http://www.tei-c.org/ns/Examples"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xml:id="learn_regexPreFormed_modern">
               <head>Regex for Modernized Texts</head>
               <p>The regular expressions in this section are used in modernized texts that were converted from IML.</p>
               <table>
                  <row role="label">
                     <cell>Rationale</cell>
                     <cell>Find</cell>
                     <cell>Replace With</cell>
                  </row>
                  <row role="data" xml:id="learn_regexPreFormed_addDivN">
                     <cell>Adds <att>n</att> attribute to <ref target="doc:lemdo_spec_div"><gi>div</gi></ref> elements</cell>
                     <cell>
                        <code>&lt;div type="(\w+)" xml:id="([a-zA-Z]+_\w*)_([a-z])(\d+)"&gt;</code>
                     </cell>
                     <cell>
                        <code>&lt;div type="$1" n="$4" xml:id="$2_$3$4"&gt;</code>
                     </cell>
                  </row>
               </table>
            </div>
            <div xmlns:lemdo="http://hcmc.uvic.ca/lemdo/ns"
                 xmlns:sch="http://purl.oclc.org/dsdl/schematron"
                 xmlns:teix="http://www.tei-c.org/ns/Examples"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xml:id="learn_regexPreFormed_otherResources">
               <head>Other Resources</head>
               <list rend="bulleted">
                  <item>LEMDO YouTube video: <ref target="https://youtu.be/ncqs5oV25WE">Modernization (Technical): Regular Expressions</ref>
                  </item>
                  <item>Jan Goyvaerts’s <ref target="https://www.regular-expressions.info/">Regular-Expressions.info</ref>
                  </item>
               </list>
            </div>
         </div>
      </body>
   </text>
</TEI>
