我正在尝试使用以下行编辑一个巨大的文件:
1 9416 0 0 10 10 0 dropitems.drop_MFighter_m012_t91_u_m00 mfighter.MFighter_m201_t201_u 0 0 0 0 0 1 0 0 icon.armor_t91_u_i00 -1 7570 46 1 2531A298 0 1 21 1 Fighter.MFighter_m201_u 1 mfighter.MFighter_m201_t201_u 2 Fighter.MFighter_m201_hrh_ad00 104 114 Fighter.MFighter_m201_hrs_ad00 115 114 2 MFighter.MFighter_m201_HRR_ad00_t201_a MFighter.MFighter_m201_HRR_ad00_t201_a 1 Fighter.FFighter_m012_u 1 FFighter.FFighter_m012_t201_u 2 Fighter.FFighter_m012_hrr_ad00 114 114 Fighter.FFighter_m012_hra_ad00 97 114 2 MFighter.MFighter_m201_HRR_ad00_t201_a MFighter.MFighter_m201_HRR_ad00_t201_a 1 DarkElf.MDarkElf_m010_u 1 MDarkElf.MDarkElf_m201_t201_u 2 DarkElf.MDarkElf_m010_Hrr_ad00 114 114 DarkElf.MDarkElf_m010_Hra_ad00 97 114 2 MDarkElf.MDarkElf_m010_HRR_ad00_t201_a MDarkElf.MDarkElf_m010_HRR_ad00_t201_a 1 DarkElf.FDarkElf_m006_u 1 FDarkElf.FDarkElf_m006_t201_u 2 DarkElf.FDarkElf_m006_hrr_ad00 114 114 DarkElf.FDarkElf_m006_hra_ad00 97 114 2 MDarkElf.MDarkElf_m010_HRR_ad00_t201_a MDarkElf.MDarkElf_m010_HRR_ad00_t201_a 1 Dwarf.MDwarf_m008_u 1 MDwarf.MDwarf_m201_t201_u 2 Dwarf.MDwarf_m008_Hrr_ad00 114 114 Dwarf.MDwarf_m008_Hra_ad00 97 114 2 MDwarf.MDwarf_m008_HRR_ad00_t201_a MDwarf.MDwarf_m008_HRR_ad00_t201_a 1 Dwarf.FDwarf_m008_u 1 FDwarf.FDwarf_m008_t201_u 2 Dwarf.FDwarf_m008_hrr_ad00 114 114 Dwarf.FDwarf_m008_hra_ad00 97 114 2 MDwarf.MDwarf_m008_HRR_ad00_t201_a MDwarf.MDwarf_m008_HRR_ad00_t201_a 1 Elf.MElf_m011_u 1 MElf.MElf_m011_t201_u 2 Elf.MElf_m011_Hrr_ad00 114 114 Elf.MElf_m011_Hra_ad00 97 114 2 MElf.MElf_m011_HRR_ad00_t201_a MElf.MElf_m011_HRR_ad00_t201_a 1 Elf.FElf_m011_u 1 FElf.FElf_m011_t201_u 2 Elf.FElf_m011_hrr_ad00 114 114 Elf.FElf_m011_hra_ad00 97 114 2 MElf.MElf_m011_HRR_ad00_t201_a MElf.MElf_m011_HRR_ad00_t201_a 1 Magic.MMagic_m011_u 1 mMagic.MMagic_m011_t301_u 2 0 255 Magic.MMagic_m011_Rra_ad00 97 114 2 Mmagic.Mmagic_m011_Rra_ad00_t301_x 1 Magic.FMagic_m013_u 1 FMagic.FMagic_m013_t301_u 2 0 255 Magic.FMagic_m013_Rra_ad00 97 114 2 Mmagic.Mmagic_m011_Rra_ad00_t301_x 1 Orc.MOrc_m007_u 1 MOrc.MOrc_m201_t201_u 2 Orc.MOrc_m007_hrh_ad00 104 114 Orc.MOrc_m007_hrs_ad00 115 114 2 MOrc.MOrc_m007_HRR_ad00_t201_a MOrc.MOrc_m007_HRR_ad00_t201_a 1 Orc.FOrc_m007_u 1 FOrc.FOrc_m007_t201_u 2 Orc.FOrc_m007_hrr_ad00 114 114 Orc.FOrc_m007_hra_ad00 97 114 2 MOrc.MOrc_m007_HRR_ad00_t201_a MOrc.MOrc_m007_HRR_ad00_t201_a 1 Shaman.MShaman_m007_u 1 MShaman.MShaman_m007_t301_u 2 0 255 Shaman.MShaman_m007_Rra_ad00 97 114 2 MShaman.MShaman_m007_Rra_ad00_t301_x 1 Shaman.FShaman_m007_u 1 FShaman.FShaman_m007_t301_u 2 0 255 Shaman.FShaman_m007_Rra_ad00 97 114 2 MShaman.MShaman_m007_Rra_ad00_t301_x 1 Kamael.mkamael_m005_u 2 MKamael.MKamael_m005_t101_u Mkamael.Mkamael_m005_t101_ut 3 Kamael.MKamael_m005_Lrr_ad00 114 114 Kamael.Mkamael_m000_w_ad00 119 95 Kamael.mkamael_m005_l_ad00 108 95 3 MKamael.MKamael_m005_Lrr_ad00_t101_a Mkamael.Mkamael_m000_t00_w Mkamael.Mkamael_m005_t101_ut 1 Kamael.fkamael_m009_u 2 FKamael.FKamael_m009_t101_u FKamael.FKamael_m009_t101_ut 3 Kamael.FKamael_m009_Lrr_ad00 114 114 Kamael.Fkamael_m000_w_ad00 119 95 Kamael.Fkamael_m009_l_ad00 108 95 3 MKamael.MKamael_m005_Lrr_ad00_t101_a Fkamael.Fkamael_m000_t00_w FKamael.FKamael_m009_t101_ut 1 1 0 0 LineageEffect.p_u002_a 4 ItemSound.armor_metal_alt_6 ItemSound.public_armor_04 ItemSound.shield_steel_1 ItemSound.shield_steel_8 ItemSound.itemdrop_armor_lightmetal ItemSound.itemequip_armor_lightmetal 1 0 2 5 0 226 0 0 36
我想出了以下正则表达式来找到类似的行:
^.*?(_t91(.*?)1 0 2 5).*?$
基本上我必须将数字5更改为数字6,我正在尝试使用以下正则表达式:
\1t91\21 0 2 6
结果是一行以't91'开头并以更换数字结束,但随后重复2-3次(即:2 6 0 226 0 0 36t91等)
你们有什么想法吗?正则表达式对我来说仍然是一个谜。
提前致谢。
答案 0 :(得分:0)
从我看到你试图将5
替换为特定环境中的整个单词。
要匹配整个单词,您需要\b
(单词边界),以便不更改55
之类的值。
要在整行上只替换一次,可以使用正则表达式
^(.*?_t91.*?1\s+0\s+2\s+)5(\b.*?)$
|-----first group------| | 2|
并替换为${1}6${2}
(虽然\16\2
也适用于此处。)
如果在一行中有多个这样的值,请使用
(_t91.*?1\s+0\s+2\s+)5\b
并替换为${1}6
。