Note that there are some explanatory texts on larger screens.

plurals
  1. POString replace with regex
    text
    copied!<p>I'm looking for a way to replace what i'd call garbage text on a doc-xml file to replace with values</p> <p>I have this program, that can grab a doc-xml to print out contracts, where the user only need to feed the program with a doc-xml file format where there will be some parameters that my program will replace with values</p> <p>lets say I have this chunk of a contract format</p> <pre><code>The Contract {@ContractNumber} specified to the contractor {@ContractorName}.... </code></pre> <p>My program looks for this parameters {@ContractNumber} and {@ContractorName} to replace with the Contract values, and i'm only asking the user to have it in a XML-DOC format, but sometimes the file it written like this</p> <pre><code>&lt;w:p w:rsidR="0094616E" w:rsidRDefault="00AC620A"&gt;&lt;w:pPr&gt;&lt;w:rPr&gt;&lt;w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman"/&gt;&lt;w:color w:val="000000"/&gt;&lt;w:sz w:val="24"/&gt;&lt;w:szCs w:val="24"/&gt;&lt;/w:rPr&gt;&lt;/w:pPr&gt;&lt;w:r&gt;&lt;w:rPr&gt;&lt;w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman"/&gt;&lt;w:color w:val="000000"/&gt;&lt;w:sz w:val="24"/&gt;&lt;w:szCs w:val="24"/&gt;&lt;/w:rPr&gt;&lt;w:t&gt;{@&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:proofErr w:type="spellStart"/&gt;&lt;w:r&gt;&lt;w:rPr&gt;&lt;w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman"/&gt;&lt;w:color w:val="000000"/&gt;&lt;w:sz w:val="24"/&gt;&lt;w:szCs w:val="24"/&gt;&lt;/w:rPr&gt;&lt;w:t&gt;ContractorNumber&lt;/w:t&gt;&lt;/w:r&gt; </code></pre> <p>and sometime it will do what i'm really hoping for</p> <pre><code>&lt;w:p w:rsidR="0094616E" w:rsidRDefault="0094616E"&gt;&lt;w:pPr&gt;&lt;w:rPr&gt;&lt;w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman"/&gt;&lt;w:color w:val="000000"/&gt;&lt;w:sz w:val="24"/&gt;&lt;w:szCs w:val="24"/&gt;&lt;/w:rPr&gt;&lt;/w:pPr&gt;&lt;w:r&gt;&lt;w:rPr&gt;&lt;w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman"/&gt;&lt;w:color w:val="000000"/&gt;&lt;w:sz w:val="24"/&gt;&lt;w:szCs w:val="24"/&gt;&lt;/w:rPr&gt;&lt;w:t&gt;{@Value1}&lt;/w:t&gt;&lt;/w:r&gt;&lt;/w:p&gt; </code></pre> <p>SO, what i'm looking for it a RegEx replace statement where i can get rid of all the garbage that can be found between open chars of my params ({@) and the closure of it (}) so it can find the entire word i'm looking to be replaced with the value assigned to it </p> <p>Edit 1:</p> <p>For a simpler understanding of my question, what i'm looking for it a ReGex that will Find everything that is between a <code>{@</code> and a subsequent <code>}</code> and when it finds <code>&lt;&gt;</code> delete them with everything within them so i have in the end <code>{@Param}</code> insted of <code>{@ &lt;garbage/&gt; Param &lt;garbage/&gt; }</code> or <code>{@Param &lt;garbage/&gt; }</code> or <code>{@Pa &lt;garbage/&gt; am}</code></p> <p>Edit 2:</p> <p>So far, the most helpfull regex has been this one</p> <pre><code>{.*?@.*?} </code></pre> <p>Giving me a result like this</p> <pre><code>{&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;@Contrato&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;} {@&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;Obrigado&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;} {@&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;Adquisicion&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;} {@&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r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t;w:r&gt;&lt;w:t&gt;CiudadOrigenAval&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;} {@&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;IFEAval&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;} {@&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;S&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;e&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;xoAval&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;} {@&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;NumeroAmortizacion&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;} {@&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;DireccionAval&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;} {@&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;ProgramaCredito&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;} {@&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;Por&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;cComisionAper&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;tura&lt;/w:t&gt;&lt;/w:r&gt;&lt;w:r&gt;&lt;w:t&gt;} </code></pre> <p>now, i need is for the Regex to get rid of all those and that are between the characters, cant seem to find a way to delete those :S</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload