たとえば、次のような文字列があります。
"{{foo-1 456}}{{foo-2 abc}} {{foo-3 ghi}}{{foo-4 456}}{{foo-5 abc}}{{foo-6ghi}}"
** **
find this position (1st) not this position (2nd)
最初の の前にあるの{{
前foo
(この場合は )の位置を見つける必要があります。foo-2
abc
foo
内容と長さは常に不明であり、foo
毎回異なる可能性がありますが、a{{
とa の間を知っており、その位置からabc
最初のものを見つけて文字列から抽出し}}
ます。
結果は
"foo-2 abc"
個別の検索を多数実行することでこれを達成できますが、これらの文字列のサイズが非常に大きくなる可能性があるため、スクリプトの速度が大幅に低下します。
最初から逆方向に検索する方法はありabc
ますか?
これは私が今使っているものです。それは機能していますが、大きくなります。
//$Temp is found by the parameter $item in another routine.
//but $Temp can change so its never the same.
//i just put it here like this so i dont have to put all the code.
$Temp = "__NOTOC__== Weak Potion of Centaur Slaying =={{Item infobox| name = Weak Potion of Centaur Slaying| icon = Weak Potion of Centaur Slaying.png| rarity = basic| description = Nourishment(30 m): +3% damage vs. centaur<BR>+10 Experience from kills| type = consumable| level = 5| value = 2}}{{Recipe| name = Weak Potion of Centaur Slaying| quantity = 5| mat-1 = Jug of Water| amt-1 =1| mat-2 = Rawhide Leather Scrap| amt-2 =1| mat-3 = Carrot| amt-3 =1| mat-4 = Pile of Glittering Dust| amt-4 =1| discipline = Artificer| level = 25}}{{clear}}== Minor Potion of Centaur Slaying =={{Item infobox| name = Minor Potion of Centaur Slaying| icon = Minor Potion of Centaur Slaying.png| rarity = basic| description = Nourishment(30 m): +5% damage vs. centaur<BR>+10 Experience from kills| type = consumable| level = 20| value = 2}}{{Recipe| name = Minor Potion of Centaur Slaying| quantity = 5| mat-1 = Jug of Water| amt-1 =1| mat-2 = Thin Leather Section | amt-2 =1| mat-3 = Carrot| amt-3 =1| mat-4 = Pile of Shimmering Dust| amt-4 =1| discipline = Artificer| level = 100}}{{clear}}== Potion of Centaur Slaying =={{Item infobox| name = Potion of Centaur Slaying| icon = Potion of Centaur Slaying.png| rarity = basic| description = Nourishment (30 m): 7% damage vs centaur<BR>-4% damage from centaur<BR>+10 Experience from kills| type = consumable| level = 35| value = 2}}{{Recipe| name = Potion of Centaur Slaying| quantity = 5| mat-1 = Jug of Water | amt-1 =1| mat-2 = Coarse Leather Section| amt-2 =1| mat-3 = Carrot| amt-3 =1| mat-4 = Pile of Radiant Dust| amt-4 =1| discipline = Artificer| level = 175}}{{clear}}== Strong Potion of Centaur Slaying =={{Item infobox| name = Strong Potion of Centaur Slaying| icon = Strong Potion of Centaur Slaying.png| rarity = basic| description = Nourishment (30 m): 8% damage vs centaur<BR>-6% damage from centaur<BR>+10 Experience from kills | type = consumable| level = 50| value = 2}}{{Recipe| name = Strong Potion of Centaur Slaying| quantity = 5| mat-1 = Jug of Water| amt-1 =1| mat-2 = Rugged Leather Section | amt-2 = 3 Carrot| amt-3 = 1| mat-4 = Pie of Luminous Dust| amt-4 = 1| discipline = Artificer| level = 250}}{{clear}}== Potent Potion of Centaur Slaying =={{Item infobox| name = Potent Potion of Centaur Slaying| icon = Potent Potion of Centaur Slaying.png| rarity = basic| description = Nourishment (30 m): 9% damage vs centaur<BR>-7% damage from centaur<BR>+10 Experience from kills | type = consumable| level = 65| value = 2}}{{Recipe| name = Potent Potion of Centaur Slaying| quantity = 5| mat-1 = Jug of Water| amt-1 =1| mat-2 = Thick Leather Section| amt-2 =1| mat-3 = Carrot| amt-3 =1| mat-4 = Pile of Incandescent Dust| amt-4 =1| discipline = Artificer| level = 325}}{{clear}}== Powerful Potion of Centaur Slaying =={{Item infobox| name = Powerful Potion of Centaur Slaying| icon = Powerful Potion of Centaur Slaying.png| rarity = basic| description = Nourishment (1 h): 10% damage vs centaur<BR>-10% damage from centaur<BR>+10 Experience from kills | type = consumable| level = 80| value = 2}}{{Recipe| name = Powerful Potion of Centaur Slaying| quantity = 10| mat-1 = Jug of Water | amt-1 =1| mat-2 = Hardened Leather Section | amt-2 =1| mat-3 = Carrot| amt-3 =1| mat-4 = Pile of Crystalline Dust| amt-4 =1 | discipline = Artificer| level = 400}}{{clear}}== Notes ==*== Trivia ==*== Bugs ==* Currently, entering the recipe for the Powerful variant of the potion in the discovery pane twice will discover the recipe for the Extended variant of the potion. These potions are identical to Powerful potions, only of Rare quality, soulbound, and worth 1c";
$Item = "Minor Potion of Centaur Slaying";
// start : is there an item infobox this time? (for the specific item)
if(stristr($Temp, '{{Item infobox |') !== FALSE)
{
// check to see if its the one i want
do
{
$Item_infobox = substr($Temp, strpos($Temp, "{{Item infobox |") + 2, strpos($Temp, "}}",strpos($Temp, "{{Item infobox |") + 2) - strpos($Temp, "{{Item infobox |") - 2);
$Temp = str_replace("{{" . $Item_infobox . "}}", "", $Temp);
if(stristr($Item_infobox, '| name = ' . $Item) !== FALSE)
{
// found it
echo $Item_infobox . "<br/><br/>";
break;
}
}
while (stristr($Temp, '{{Item infobox |') !== FALSE);
}
// stop : is it an item infobox this time? (for the specific item)
// start : is there an crafting infobox this time? (for the specific item)
if(stristr($Temp, '{{Crafting infobox |') !== FALSE)
{
// check to see if its the one i want
do
{
$Crafting_infobox = substr($Temp, strpos($Temp, "{{Crafting infobox |") + 2, strpos($Temp, "}}",strpos($Temp, "{{Crafting infobox |") + 2) - strpos($Temp, "{{Crafting infobox |") - 2);
$Temp = str_replace("{{" . $Crafting_infobox . "}}", "", $Temp);
if(stristr($Crafting_infobox, '| name = ' . $Item) !== FALSE)
{
// found it
echo $Crafting_infobox . "<br/><br/>";
break;
}
}
while (stristr($Temp, '{{Crafting infobox |') !== FALSE);
}
// stop : is it an crafting infobox this time? (for the specific item)
// repeat this routine for every different infobox (around 50) until i find the correct one.
一緒に属する $Temp と $Item の他の例を次に示します。また。$temp は時間の経過とともに変化するため、$item に従って毎回 $temp を取得する必要があります。これは、文字列がどれほど多様であるかを示すためのものです。
//exammple 2
$Temp = "{{stub}}{{Crafting infobox| name = Gift of Color| type = legendary| description = A gift of color used to create [[The Bifrost]].| rarity = legendary }}==Acquisition==A [[Gift of Color]] can be crafted by a level 400 [[Cook]]. The required [[Recipe: Gift of Color]] can be bought from [[Miyani]] at the [[Mystic Forge]].{{Recipe | name = Gift of Color| mat-1 = Pile of Crystalline Dust| amt-1 = 250| mat-2 = Opal Orb| amt-2 = 100| mat-3 = Gift of Zhaitan| amt-3 = 1| mat-4 = Unidentified Dye| amt-4 = 250|discipline=Chef|level=400|exp}}";
$Item = "Gift of Color";
//exammple 3
$Temp = "{{Inventory infobox| name = 20 Slot Safe Box| slots= 20| property =| description = 20 Slots, Items in this box will never appear in a sell-to-vendor list and will not move when inventory is sorted.| rarity = fine| type = box| value = 54}}{{clear}}== Recipes =={{Recipe| name = 20 Slot Safe Box| mat-1 = Orichalcum Ingot| amt-1 = 10| mat-2 = Superior Rune of Holding| amt-2 = 1| mat-3 = Pile of Crystalline Dust| amt-3 = 3| discipline = Armorsmith| level = 400}}==See also==*[[20 Slot Invisible Bag]]*[[20 Slot Invisible Leather Pack]][[Category:Armorsmith recipes]]";
$Item = "20 Slot Safe Box";