0

現在、データを解析するための次の正規表現があります。そして、「除外」の配列

$userNameArray = (userName1, user Name2, User Name 3);

$re = '/^(?<timeMined>[0-9]{2}:[0-9]{2}:[0-9]{2}) # timeMined 
     \s+
     (?<userName>[\w\s]+)        # user name
     \s+(?:has\s+looted)\s+    # garbage text between name and amount
     (?<amount>\d+)              # amount
     \s+x\s+                     # multiplication symbol
     (?<item>.*?)\s*$            # item name (to end of line)
   /xmu';
preg_match_all($re, $sample, $matches, PREG_SET_ORDER);
foreach ($matches as $value){
    code
}

私のコードには現在、コードの一部を実行する if ステートメントがあり、$value['userName']そう$userNameArrayでない場合は別の部分を実行します。ただし、正規表現で悪いユーザーを解析できれば、これは非常に簡単になります。

4

1 に答える 1