title: Regex that matches a string but only if another string is not present anywhere on the same line
body: <p>I am using many different Regex implementations as this happens on several systems (Linux, Windows, VS, notepad++, etc.); it's just where I have a customer who wants to remove auto sizing. The intent is to use regex in which ever tool to find any line that has a width but doesn't have an autowidth and then <strong>add</strong> autowidth. I am just asking about how to find it, <em>but I intend to then use what I find here in a replacement string for my given editor.</em> I have the replacement bit down: I just haven't figured out how to get one with out the other when the other is far away from the one.</p>
  
  <p>Using <a href="https://regex101.com/" rel="nofollow noreferrer">https://regex101.com/</a> I've tried literally dozens of search strings. </p>
  
  <p>This was my starting point for a search string and a couple of attempts to get the lookarounds to exclude AutoWidth anywhere on the line. String 2 and 3 are basically the same thing, but I didn't know what else to try. I assume that anything that works for the lookbehind will work for the lookahead, but as you can see, I can't even the behind working.</p>
  
  <blockquote>
  <pre><code>(?&lt;! AutoWidth="false") width="\d*"(?! AutoWidth="false")
  (?&lt;! AutoWidth="false").*? width="\d*"(?! AutoWidth="false")
  (?&lt;! AutoWidth="false")[0-9a-zA-Z" =]*? width="\d*"(?! AutoWidth="false")
  </code></pre>
  </blockquote>
  
  <p>I'm stuck, putting distance between AutoWidth and width is eluding me.</p>
  
  <p>These are my targets </p>
  
  <blockquote>
  <pre><code>1-&gt;  &lt;column name="Selected" AutoWidth="false" IsEditable="true" datatype="bool" width="20"/&gt;
  2-&gt;  &lt;column width="40" AutoWidth="false" name="ExternalIdOrEmpty" index="XIDname" sort="true"/&gt;
  3-&gt;  &lt;column width="40" name="Tax Rate" index="TRname" sort="true" AutoWidth="false"/&gt;
  4-&gt;  &lt;column width="40" name="Total Tax" index="TTname" sort="true"/&gt;
  5-&gt;  &lt;column name="Tax Deductible" index="TDname" sort="true"/&gt;
  </code></pre>
  </blockquote>
  
  <p>I want to find all lines that contain</p>
  
  <blockquote>
    <p>width="\d*"</p>
  </blockquote>
  
  <p>but that do not contain</p>
  
  <blockquote>
    <p>AutoWidth="\d*"</p>
  </blockquote>
  
  <p>anywhere on the same line.</p>
  
  <p>This means that only line 4, in the samples above, would match my criteria.</p>
  
  <p>UPDATE:</p>
  
  <p>I am willing to use any other tool that will get the job done. So XSLT, etc. are all good. The only requirement there is that the tool is generally available on Windows, Linux, &amp; Mac, AND is either open source or free and is also well known.</p>
  
  <p>The full xml is huge. The edit function here is limited to 30,00 characters but here's a good sample.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;spread&gt;
    &lt;ViewPatientOutboundReferralFilter&gt;
      &lt;FindColumn name="ViewUid" index="guid" visible="false" /&gt;
      &lt;FindColumn name="Selected" caption=" " visible="true" IsEditable="true" datatype="bool"/&gt;
      &lt;FindColumn name="PatientName" caption="Patient Name" visible="true" width="150" hyperlink="true" AutoWidth="false"/&gt;
      &lt;FindColumn name="ReferToProviderName" caption="Provider" visible="true" AutoWidth="false" width="150" hyperlink="true"/&gt;
      &lt;FindColumn name="ReferredToMedicalServicesProviderName" caption="Medical Services Provider" visible="true" width="150" hyperlink="true"/&gt;
      &lt;FindColumn name="ProviderRole" caption="Provider Role" visible="true" width="80" hyperlink="true"/&gt;
      &lt;FindColumn name="StatusName" caption="Current Status" visible="true" width="100" hyperlink="true"/&gt;
      &lt;FindColumn name="ServiceSiteName" caption="Service Site" visible="true"/&gt;
      &lt;FindColumn name="VisitDate" caption="Visit Date" visible="true" width="90" datatype="date"/&gt;
      &lt;FindColumn name="AppointmentDate" caption="Appointment Date" visible="true" datatype="datetime" width="90"/&gt;
      &lt;FindColumn name="Notes" caption="Comments" visible="true" width="120"/&gt;
      &lt;FindColumn name="AppointmentNotes" caption="Referral Notes" visible="true" width="120"/&gt;
      &lt;FindColumn name="DisplayName" visible="false" index="name"  /&gt;
      &lt;FindColumn name="ProviderUid" visible="false" storeproperty="true" /&gt;
      &lt;FindColumn name="VisitUid" visible="false" storeproperty="true" /&gt;
      &lt;FindColumn name="CreatedDate" caption="Created Date" visible="true" datatype="date" width="90"/&gt;
      &lt;FindColumn name="RequestingName" caption="Requesting Provider" visible="true" width="150" /&gt;
    &lt;/ViewPatientOutboundReferralFilter&gt;
    &lt;FeeScheduleFeeAA rowcount="3"&gt;
      &lt;column row="0" rowspan="3" caption="Code" width="50" name="Procedure.Code" sort="true" index="name" /&gt;
      &lt;column row="0" rowspan="3" caption="Description" relwidth="100%" width="80" AutoWidth="false" name="Procedure.ShortDescription" sort="true" /&gt;
      &lt;column row="0" rowspan="3" caption="Amount Allowed" width="60" AutoWidth="false" name="Fee" IsEditable="true" datatype="currency" /&gt;
      &lt;column row="0" rowspan="3" caption="Global Period" width="40" AutoWidth="false" name="GlobalPeriodDays" IsEditable="true" datatype="number" decimalPlaces="0" minValue="0" maxValue="1000" /&gt;
      &lt;column row="0" colspan="5" caption="Coinsurance" /&gt;
      &lt;column row="1" colspan="2" caption="Insurance Percent" /&gt;
      &lt;column row="2" caption=" " width="30" AutoWidth="false" name="RadioInsurancePercent" IsEditable="true" datatype="radio" radioOrientation="vertical" radioItems=" " /&gt;
      &lt;column row="2" caption="Value" width="70" AutoWidth="false" name="InsurancePercent" IsEditable="true" datatype="number" decimalPlaces="0" minValue="0" maxValue="100" /&gt;
      &lt;column row="1" colspan="2" caption="Insurance Plan" /&gt;
      &lt;column row="2" caption="PCP/Specialist" width="95" AutoWidth="false" name="RadioInsurancePlanPhysician" IsEditable="true" datatype="radio" radioOrientation="vertical" radioItems=" " /&gt;
      &lt;column row="2" caption="Other" width="55" AutoWidth="false" name="RadioInsurancePlanOther" IsEditable="true" datatype="radio" radioOrientation="vertical" radioItems=" " /&gt;
      &lt;column row="1" rowspan="2" caption="Copay Amount" width="70" AutoWidth="false" name="FixedCopayAmount" datatype="currency" IsEditable="true" /&gt;
      &lt;column row="0" rowspan="3" caption="Contract Type" width="55" AutoWidth="false" name="ContractTypeCode.Name" sort="true"/&gt;
      &lt;column row="0" rowspan="3" caption="Family Planning" width="55" AutoWidth="false" name="FamilyPlanning" IsEditable="true" datatype="bool" /&gt;
      &lt;column row="0" rowspan="3" caption="Alt Insurance Plan" width="55" AutoWidth="false" name="UseAlternateInsurancePlan" IsEditable="true" datatype="bool" /&gt;
      &lt;column row="0" rowspan="3" caption="Edit Billing Rule" width="70" visible="false" IsEditable="true" datatype="CustomCellType" celltype="iMedica.Prm.Client.UI.BaseControls.Spread.PrmNeoCellImageButton,iMedica.Prm.Client.UI.BaseControls" ShowSortIndicator="false" ImageResourceName="iMedica.Prm.Client.UI.BaseControls.Icons.BillingRule.png" ImageResourceAssembly="iMedica.Prm.Client.UI.BaseControls" sort="false" /&gt;
    &lt;/FeeScheduleFeeAA&gt;
  &lt;/spread&gt;
  </code></pre>