Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 83625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:48:10+00:00 2026-05-10T21:48:10+00:00

I have below a list of text, it is from a popular online game

  • 0

I have below a list of text, it is from a popular online game called EVE Online and this basically gets mailed to you when you kill a person in-game. I’m building a tool to parse these using PHP to extract all relevant information. I will need all pieces of information shown and i’m writting classes to nicely break it into relevant encapsulated data.

2008.06.19 20:53:00  Victim: Massi Corp: Cygnus Alpha Syndicate Alliance: NONE Faction: NONE Destroyed: Raven System: Jan Security: 0.4 Damage Taken: 48436  Involved parties:  Name: Kale Kold Security: -10.0 Corp: Vicious Little Killers Alliance: NONE Faction: NONE Ship: Drake Weapon: Hobgoblin II Damage Done: 22093  Name: Harulth (laid the final blow) Security: -10.0 Corp: Vicious Little Killers Alliance: NONE Faction: NONE Ship: Drake Weapon: Caldari Navy Scourge Heavy Missile Damage Done: 16687  Name: Gistatis Tribuni / Angel Cartel Damage Done: 9656  Destroyed items:  Capacitor Power Relay II, Qty: 2 Paradise Cruise Missile, Qty: 23 Cataclysm Cruise Missile, Qty: 12 Small Tractor Beam I Alloyed Tritanium Bar, Qty: 2 (Cargo) Paradise Cruise Missile, Qty: 1874 (Cargo) Contaminated Nanite Compound (Cargo) Capacitor Control Circuit I, Qty: 3 Ballistic Deflection Field I 'Malkuth' Cruise Launcher I, Qty: 3 Angel Electrum Tag, Qty: 2 (Cargo)  Dropped items:  Ballistic Control System I Shield Boost Amplifier I, Qty: 2 Charred Micro Circuit, Qty: 4 (Cargo) Capacitor Power Relay II, Qty: 2 Paradise Cruise Missile, Qty: 10 Cataclysm Cruise Missile, Qty: 21 X-Large Shield Booster II Cataclysm Cruise Missile, Qty: 3220 (Cargo) Fried Interface Circuit (Cargo) F-S15 Braced Deflection Shield Matrix, Qty: 2 Salvager I 'Arbalest' Cruise Launcher I 'Malkuth' Cruise Launcher I, Qty: 2 

I’m thinking about using regular expressions to parse the data but how would you approach this? Would you collapse the mail into a one line string or parse each line from an array? The trouble is there are a few anomalies to account for.

First, the ‘Involved parties:’ section is dynamic and can contain lots of people all with the similar structure as below but if a computer controlled enemy takes a shot at the victim too, it gets shortened to only the ‘Name’ and ‘Damage Done’ fields, as shown above (Gistatis Tribuni / Angel Cartel).

Second, the ‘Destroyed’ and ‘Dropped’ items are dynamic and will be different lengths on each mail and i will also need to get the quantity and wether or not they are in cargo.

Ideas for an approach are welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:48:11+00:00Added an answer on May 10, 2026 at 9:48 pm

    If you want something flexible, use the state machine approach.

    If you want something quick and dirty, use regexp.

    For the first solution, you can use libraries that are specialized in parsin since it’s not a trivial task. But because it’s fairly simple format, you can hack a naive parser, as for example :

    <?php  class Parser  {    /* Enclosing the parser in a class is not mandatory but it' clean */      function Parser()     {          /* data holder */         $this->date = '';         $this->parties = array();         $this->victim = array();         $this->items = array('Destroyed' => array(),                                             'Dropped' => array());          /* Map you states on actions. Sub states can be necessary (and sub parsers too :-) */                            $this->states = array('Victim' => 'victim_parsing',                                              'Involved' => 'parties_parsing' ,                                              'items:' => 'item_parsing');           $this->state = 'start';                               $this->item_parsing_state = 'Destroyed';              $this->partie_parsing_state = '';                    $this->parse_tools = array('start' => 'start_parsing',                                            'parties_parsing' =>'parties_parsing',                                            'item_parsing' => 'item_parsing',                                            'victim_parsing' => 'victim_parsing');       }      /* the magic job is done here */      function checkLine($line)      {         foreach ($this->states as $keyword => $state)              if (strpos($line, $keyword) !== False)                     $this->state = $this->states[$keyword];          return trim($line);     }      function parse($file)     {         $this->file = new SplFileObject($file);         foreach ($this->file as $line)              if ($line = $this->checkLine($line))                  $this->{$this->parse_tools[$this->state]}($line);     }       /* then here you can define as much as parsing rules as you want */      function victim_parsing($line)      {         $victim_caract = explode(': ', $line);         $this->victim[$victim_caract[0]] = $victim_caract[1];     }      function start_parsing($line)     {         $this->date = $line;     }      function item_parsing($line)      {         if (strpos($line, 'items:') !== False)         {             $item_state = explode(' ', $line);             $this->item_parsing_state = $item_state[0];         }              else           {                $item_caract = explode(', Qty: ', $line);                $this->items[$this->item_parsing_state][$item_caract[0]] = array();                $item_infos =  explode(' ', $item_caract[1]);                $this->items[$this->item_parsing_state][$item_caract[0]] ['qty'] = empty($item_infos[0]) ? 1 : $item_infos[0];                $this->items[$this->item_parsing_state][$item_caract[0]] ['cargo'] = !empty( $item_infos[1]) ? 'True':  'False';                if  (empty( $this->items[$this->item_parsing_state][$item_caract[0]] ['qty'] ))                 print $line;          }     }      function parties_parsing($line)      {                  $partie_caract = explode(': ', $line);          if ($partie_caract[0] == 'Name')         {             $this->partie_parsing_state = $partie_caract[1];             $this->parties[ $this->partie_parsing_state ] = array();         }         else             $this->parties[ $this->partie_parsing_state ][$partie_caract[0]] = $partie_caract[1];      }  }  /* a little test */  $parser = new Parser(); $parser->parse('test.txt');  echo '======== Fight report - '.$parser->date.' ==========\n\n'; echo 'Victim :\n\n'; print_r($parser->victim); echo 'Parties :\n\n'; print_r($parser->parties); echo 'Items: \n\n'; print_r($parser->items);  ?> 

    We can do that because here, reliability and perf are not an issue 🙂

    Happy game !

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 69k
  • Answers 69k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Uhm... 'nasty' is in the way the constructor handles the… May 11, 2026 at 12:45 pm
  • added an answer XmlElement( IsNullable = true ) May 11, 2026 at 12:45 pm
  • added an answer Yes, you can specify the repository locations if you use… May 11, 2026 at 12:45 pm

Related Questions

I have a list of items (blue nodes below) which are categorized by the
I have a comma separated list of strings like the one below. a,b ,c
I have a little demonstration below of a peculiar problem. using System; using System.Windows.Forms;
Below I have a very simple example of what I'm trying to do. I
I have a big load of documents, text-files, that I want to search for
I know it might not be according to Apple's human interface guidelines for the
I am trying to make the Validation plugin work. It works fine for individual
I am writing a piece of code that to work would require an extensive

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.