我使用许多不同的正则表达式实现,因为这发生在几个系统上(Linux,Windows,VS,记事本++等);这正是我有一个客户想要删除自动调整大小的地方。意图是使用正则表达式,其中有史以来的工具来找到任何有宽度,但没有自动宽度的行,然后加上 autowidth。我只是问如何找到它,,但我打算然后使用我在这里找到的替代字符串中的给定编辑器。我有替换位:我只是没有想出如何让另一个远离另一个。正则表达式匹配一个字符串,但只有当另一个字符串不存在于同一行上的任何地方
使用https://regex101.com/我尝试了几十个搜索字符串。
这是我的搜索字符串的起点和一些尝试获取查找排除行上任何地方的AutoWidth的尝试。字符串2和3基本上是一样的东西,但我不知道还有什么要尝试的。我认为任何可以用于后视的东西都可以用于预测,但正如你所看到的,我甚至不能在后面工作。
(?<! AutoWidth="false") width="\d*"(?! AutoWidth="false") (?<! AutoWidth="false").*? width="\d*"(?! AutoWidth="false") (?<! AutoWidth="false")[0-9a-zA-Z" =]*? width="\d*"(?! AutoWidth="false")
我卡住了,把正在躲避我AutoWidth和宽度之间的距离。
这是我的目标
1-> <column name="Selected" AutoWidth="false" IsEditable="true" datatype="bool" width="20"/> 2-> <column width="40" AutoWidth="false" name="ExternalIdOrEmpty" index="XIDname" sort="true"/> 3-> <column width="40" name="Tax Rate" index="TRname" sort="true" AutoWidth="false"/> 4-> <column width="40" name="Total Tax" index="TTname" sort="true"/> 5-> <column name="Tax Deductible" index="TDname" sort="true"/>
我想找到包含
宽度的所有行= “\ d *”
,但不包含
AutoWidth = “\ d *”
在同一行上的任何地方。
这意味着只有第4行在上面的示例中符合我的标准。
UPDATE:
我愿意使用任何其他工具,将完成这项工作。所以XSLT等都很好。唯一的要求是,该工具通常可在Windows,Linux,Mac上使用,AND既可以是开源的,也可以是免费的,也是众所周知的。
完整的XML是巨大的。这里的编辑功能限制为30,00个字符,但这里有一个很好的示例。
<?xml version="1.0" encoding="utf-8" ?>
<spread>
<ViewPatientOutboundReferralFilter>
<FindColumn name="ViewUid" index="guid" visible="false" />
<FindColumn name="Selected" caption=" " visible="true" IsEditable="true" datatype="bool"/>
<FindColumn name="PatientName" caption="Patient Name" visible="true" width="150" hyperlink="true" AutoWidth="false"/>
<FindColumn name="ReferToProviderName" caption="Provider" visible="true" AutoWidth="false" width="150" hyperlink="true"/>
<FindColumn name="ReferredToMedicalServicesProviderName" caption="Medical Services Provider" visible="true" width="150" hyperlink="true"/>
<FindColumn name="ProviderRole" caption="Provider Role" visible="true" width="80" hyperlink="true"/>
<FindColumn name="StatusName" caption="Current Status" visible="true" width="100" hyperlink="true"/>
<FindColumn name="ServiceSiteName" caption="Service Site" visible="true"/>
<FindColumn name="VisitDate" caption="Visit Date" visible="true" width="90" datatype="date"/>
<FindColumn name="AppointmentDate" caption="Appointment Date" visible="true" datatype="datetime" width="90"/>
<FindColumn name="Notes" caption="Comments" visible="true" width="120"/>
<FindColumn name="AppointmentNotes" caption="Referral Notes" visible="true" width="120"/>
<FindColumn name="DisplayName" visible="false" index="name" />
<FindColumn name="ProviderUid" visible="false" storeproperty="true" />
<FindColumn name="VisitUid" visible="false" storeproperty="true" />
<FindColumn name="CreatedDate" caption="Created Date" visible="true" datatype="date" width="90"/>
<FindColumn name="RequestingName" caption="Requesting Provider" visible="true" width="150" />
</ViewPatientOutboundReferralFilter>
<FeeScheduleFeeAA rowcount="3">
<column row="0" rowspan="3" caption="Code" width="50" name="Procedure.Code" sort="true" index="name" />
<column row="0" rowspan="3" caption="Description" relwidth="100%" width="80" AutoWidth="false" name="Procedure.ShortDescription" sort="true" />
<column row="0" rowspan="3" caption="Amount Allowed" width="60" AutoWidth="false" name="Fee" IsEditable="true" datatype="currency" />
<column row="0" rowspan="3" caption="Global Period" width="40" AutoWidth="false" name="GlobalPeriodDays" IsEditable="true" datatype="number" decimalPlaces="0" minValue="0" maxValue="1000" />
<column row="0" colspan="5" caption="Coinsurance" />
<column row="1" colspan="2" caption="Insurance Percent" />
<column row="2" caption=" " width="30" AutoWidth="false" name="RadioInsurancePercent" IsEditable="true" datatype="radio" radioOrientation="vertical" radioItems=" " />
<column row="2" caption="Value" width="70" AutoWidth="false" name="InsurancePercent" IsEditable="true" datatype="number" decimalPlaces="0" minValue="0" maxValue="100" />
<column row="1" colspan="2" caption="Insurance Plan" />
<column row="2" caption="PCP/Specialist" width="95" AutoWidth="false" name="RadioInsurancePlanPhysician" IsEditable="true" datatype="radio" radioOrientation="vertical" radioItems=" " />
<column row="2" caption="Other" width="55" AutoWidth="false" name="RadioInsurancePlanOther" IsEditable="true" datatype="radio" radioOrientation="vertical" radioItems=" " />
<column row="1" rowspan="2" caption="Copay Amount" width="70" AutoWidth="false" name="FixedCopayAmount" datatype="currency" IsEditable="true" />
<column row="0" rowspan="3" caption="Contract Type" width="55" AutoWidth="false" name="ContractTypeCode.Name" sort="true"/>
<column row="0" rowspan="3" caption="Family Planning" width="55" AutoWidth="false" name="FamilyPlanning" IsEditable="true" datatype="bool" />
<column row="0" rowspan="3" caption="Alt Insurance Plan" width="55" AutoWidth="false" name="UseAlternateInsurancePlan" IsEditable="true" datatype="bool" />
<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" />
</FeeScheduleFeeAA>
</spread>
了解如何使用HTML解析器和你的日子会更快乐。对于python:'beautifulsoup',对于java:'jsoup',对于php:'DOMDocument'等等...... –
@PedroLobito他的html解析器是什么类型的?它可以帮助我解决我的XML问题吗? –
xpath很简单。正则表达式解决方案看起来很难。 –