Notepad++ 正则表达式查找和替换:匹配但不包含运算符 ?<= 不起作用。为什么?
Notepad++ regex find-and-replace: Match-but-dont-include operator ?<= doesn't work. Why?
我正在尝试使用 Notepad++ 的查找和替换对话框来大写 .ssdl 文件的某些部分。我使用的配置是这个:
Regex: (?i)(?<=[<]EntitySet.*?EntityType="Self[.]).*?(?=")
Replacement Text: \U
然而,代表 "match-but-dont-include" 的 ?<= 运算符似乎不受支持或类似的东西。有没有办法让事情正常进行?我定位的文件是一个 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>
NPP 使用不支持无限宽度回顾的 Boost 正则表达式引擎。替换为 \K
:
的结构
Find: (?i)<EntitySet[^<]*?EntityType="Self\.\K[^"]+
Replace: \U[=10=]
详情
(?i)
- 不区分大小写的内联修饰符
<EntitySet
- 文字子串
[^<]*?
- <
以外的任何 0+ 个字符尽可能少
EntityType="Self\.
- 文字 EntityType="Self.
子串
\K
- 匹配重置运算符
[^"]+
- "
以外的 1+ 个字符(尽可能多)。
\U
使后面的文字大写,后面的文字是[=22=]
,整个匹配。
我正在尝试使用 Notepad++ 的查找和替换对话框来大写 .ssdl 文件的某些部分。我使用的配置是这个:
Regex: (?i)(?<=[<]EntitySet.*?EntityType="Self[.]).*?(?=")
Replacement Text: \U
然而,代表 "match-but-dont-include" 的 ?<= 运算符似乎不受支持或类似的东西。有没有办法让事情正常进行?我定位的文件是一个 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>
NPP 使用不支持无限宽度回顾的 Boost 正则表达式引擎。替换为 \K
:
Find: (?i)<EntitySet[^<]*?EntityType="Self\.\K[^"]+
Replace: \U[=10=]
详情
(?i)
- 不区分大小写的内联修饰符<EntitySet
- 文字子串[^<]*?
-<
以外的任何 0+ 个字符尽可能少EntityType="Self\.
- 文字EntityType="Self.
子串\K
- 匹配重置运算符[^"]+
-"
以外的 1+ 个字符(尽可能多)。
\U
使后面的文字大写,后面的文字是[=22=]
,整个匹配。