Jump to content

Converting some text into a formatted text


joe12

Recommended Posts

I'm really not sure how to go about this because I have never actually looked into regex at all.

 

But say I was to convert the following text exactly -

 

At 08-04 23:34:14 the following fleets met in battle::

Attacker Lewis ([1:24:4])
Weapons: 0% Shields: 0% Armour: 20%
Type	S.Cargo
Total	1
Weapons	5
Shields	10
Armour	480

Defender DarksuN ([1:19:5])
Weapons: 0% Shields: 0% Armour: 10%
destroyed

The attacker has won the battle!
He captured
2.417 metal, 1.358 crystal, and 474 deuterium


The attacker lost a total of 0 units.
The defender lost a total of 0 units.
At these space coordinates now float 0 metal and 0 crystal. 

 

 

 

And change it into something like this using regex -

 

[center]The following fleets were engaged in battle!

 Attacker  
Lewis

S.Cargo .::. 1


 Defender  
DarksuN

destroyed
[color=red]
[hr]
The attacker has won the battle!
[hr][/color]

.::. What was stolen .::.
[color=green]+2.417[/color] metal
[color=green]+1.358[/color] crystal
[color=green]+474[/color] deuterium


Attacker Unit Loss .:.
Defender Unit Loss .:.
Debris Floating .:. 0 Metal, 0 Crystal [/center]

 

 

If anyone could explain to me how I could do this, thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.