Notepad ++ regex find-and-replace:Match-but-dont-include运算符?< =不起作用。为什么?

时间:2018-03-07 12:42:57

标签: regex replace notepad++ pcre

我尝试使用Notepad ++的查找和替换对话框来大写整理.ssdl文件的某些部分。我使用的配置就是这个:

Regex: (?i)(?<=[<]EntitySet.*?EntityType="Self[.]).*?(?=")
Replacement Text: \U$1

然而,&lt; =运算符代表&#34;匹配但不包括&#34;似乎没有得到支持或其他什么。有没有办法使事情有效?我定位的文件是ssdl文件:

<?xml version="1.0" encoding="utf-8" ?>
<Schema     Alias="Self"
            Provider="MySql.Data.MySqlClient"
            Namespace="Organotiki.Infrastructure.Core.Store"
            ProviderManifestToken="5.7"
            xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl"
            xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator"
            xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation">
  <EntityType Name="dbid">
    <Key>
      <PropertyRef Name="DBD_SHORT_NAME" />
    </Key>
    <Property Name="DBD_SHORT_NAME" Type="varchar" MaxLength="10" Nullable="false" />
    <Property Name="DBD_DBTYPE" Type="varchar" MaxLength="1" Nullable="false" />
    <Property Name="DBD_ENCODING" Type="varchar" MaxLength="1" Nullable="false" />
    <Property Name="DBD_INST_DATE" Type="decimal" Precision="8" Scale="0" />
    <Property Name="DBD_VERSION" Type="varchar" MaxLength="50" />
    <Property Name="DBD_LAST_UPDATED" Type="decimal" Precision="8" Scale="0" />
    <Property Name="DBD_VERSION_NR" Type="varchar" MaxLength="20" />
    <Property Name="DBD_SW_VERSION_NR" Type="varchar" MaxLength="20" />
  </EntityType>
  <EntityType Name="gn_setup_vars">
    <Key>
      <PropertyRef Name="GSV_GROUP" />
      <PropertyRef Name="GSV_NAME" />
      <PropertyRef Name="GSV_FROM_DT" />
    </Key>
    <Property Name="GSV_GROUP" Type="varchar" MaxLength="50" Nullable="false" />
    <Property Name="GSV_NAME" Type="varchar" MaxLength="50" Nullable="false" />
    <Property Name="GSV_TYPE" Type="decimal" Precision="4" Scale="0" Nullable="false" />
    <Property Name="GSV_VALUE" Type="varchar" MaxLength="512" Nullable="false" />
    <Property Name="GSV_FROM_DT" Type="decimal" Precision="8" Scale="0" Nullable="false" />
    <Property Name="GSV_TO_DT" Type="decimal" Precision="8" Scale="0" />
    <Property Name="GSV_NOTES" Type="varchar" MaxLength="200" />
  </EntityType>
  <EntityType Name="sequences">
    <Key>
      <PropertyRef Name="SEQ_NAME" />
    </Key>
    <Property Name="SEQ_NAME" Type="varchar" MaxLength="50" Nullable="false" />
    <Property Name="SEQ_NEXT_ID" Type="decimal" Precision="11" Scale="0" Nullable="false" />
    <Property Name="SEQ_INCREMENT" Type="decimal" Precision="2" Scale="0" Nullable="false" />
  </EntityType>
  <EntityType Name="software_properties">
    <Key>
      <PropertyRef Name="SPE_ID" />
    </Key>
    <Property Name="SPE_ID" Type="decimal" Precision="11" Scale="0" Nullable="false" />
    <Property Name="SPE_SFT_CODE" Type="varchar" MaxLength="8" Nullable="false" />
    <Property Name="SPE_NAME" Type="varchar" MaxLength="50" Nullable="false" />
  </EntityType>
  <EntityType Name="sw_user_properties">
    <Key>
      <PropertyRef Name="SUE_ID" />
    </Key>
    <Property Name="SUE_ID" Type="decimal" Precision="11" Scale="0" Nullable="false" />
    <Property Name="SUE_USER_ID" Type="decimal" Precision="11" Scale="0" Nullable="false" />
    <Property Name="SUE_PROPERTY_ID" Type="decimal" Precision="11" Scale="0" Nullable="false" />
  </EntityType>
  <Association Name="SUE_SPE_FK">
    <End Role="software_properties" Type="Self.software_properties" Multiplicity="1" />
    <End Role="sw_user_properties" Type="Self.sw_user_properties" Multiplicity="*" />
    <ReferentialConstraint>
      <Principal Role="software_properties">
        <PropertyRef Name="SPE_ID" />
      </Principal>
      <Dependent Role="sw_user_properties">
        <PropertyRef Name="SUE_PROPERTY_ID" />
      </Dependent>
    </ReferentialConstraint>
  </Association>
  <EntityContainer Name="OrganotikiInfrastructureCoreStoreContainer">
    <EntitySet Name="dbid" EntityType="Self.dbid" Schema="niobe" store:Type="Tables" />
    <EntitySet Name="gn_setup_vars" EntityType="Self.gn_setup_vars" Schema="niobe" store:Type="Tables" />
    <EntitySet Name="sequences" EntityType="Self.sequences" Schema="niobe" store:Type="Tables" />
    <EntitySet Name="software_properties" EntityType="Self.software_properties" Schema="niobe" store:Type="Tables" />
    <EntitySet Name="sw_user_properties" EntityType="Self.sw_user_properties" Schema="niobe" store:Type="Tables" />
    <AssociationSet Name="SUE_SPE_FK" Association="Self.SUE_SPE_FK">
      <End Role="software_properties" EntitySet="software_properties" />
      <End Role="sw_user_properties" EntitySet="sw_user_properties" />
    </AssociationSet>
  </EntityContainer>
</Schema>

1 个答案:

答案 0 :(得分:2)

NPP使用不支持无限宽度外观的Boost正则表达式引擎。替换为\K

的结构
Find:    (?i)<EntitySet[^<]*?EntityType="Self\.\K[^"]+
Replace: \U$0

<强>详情

  • (?i) - 不区分大小写的内联修饰符
  • <EntitySet - 文字子字符串
  • [^<]*? - 尽可能少的<以外的任何0 +字符
  • EntityType="Self\. - 文字EntityType="Self.子字符串
  • \K - 匹配重置运算符
  • [^"]+ - "以外的1个字符(尽可能多)。

\U生成大写字母,后面的文字为$0,整个匹配。

enter image description here