\r\n\r\n
Regular Expressions Topics include: System.Text.RegularExpressions classes, and .NET regular expression syntax.

Go Back  Xtreme .NET Talk > .NET > Regular Expressions > Regular Expression N00bie needs help :P


\r\n \r\n \r\n \r\n
 
 
Thread Tools Display Modes
\r\n \r\n
\r\n
\r\n \r\n I am actually coding a map-loader class for my game. In the beginning the map format was quite simple, and i could just read line after line and put things together. Now, my mapformat is getting more complicated, and its much easier to make the whole thing crash. I have done some PHP and i know what regular expressions are, but i never bothered to learn them (mostly because i never needed them), but i think thats the thing i have to use..
\r\n
\r\nMy maps are separated into four sections. Config, Terrain data, Object data and Trigger data. I want to read the whole file, then split it up using reg expr. To clearify this i\'ll make an example:
\r\n
\r\nThe map:
\r\n
\r\n
Code:
\r\n
[MAP_CONFIG:\r\nmap_name=Testmap\r\nmap_tileset=Default\r\n]\r\n[MAP_TERRAIN_DATA:\r\n0;1;0;1;0;1;0;1;\r\n0;1;0;1;0;1;0;1;\r\n0;1;0;1;0;1;0;1;\r\n0;1;0;1;0;1;0;1;\r\n]\r\n[MAP_OBJECT_DATA:\r\ntree{pos=2,2;}\r\ntree{pos=6,3;}\r\n]\r\n[MAP_TRIGGER_DATA:\r\nhurt{pos=0,0;dmgamount=10;}\r\n]
\r\n
Here i\'d like to separate the config, terrain data etc, like this:
\r\n
\r\nConfigVar =
\r\n
\r\n
Code:
\r\n
map_name=Testmap\r\nmap_tileset=Default
\r\n
TerrainDataVar =
\r\n
\r\n
Code:
\r\n
0;1;0;1;0;1;0;1;\r\n0;1;0;1;0;1;0;1;\r\n0;1;0;1;0;1;0;1;\r\n0;1;0;1;0;1;0;1;
\r\n
etc...
\r\n
\r\nI really have no ideas how to do this. If you know some good tutorials, please post them here. Suggestions?? I dont care if i have to change the map format a little...
\r\n
\r\n-' + '- Loffen\r\n
\r\n
\r\n \r\n
\r\n \r\n\r\n \r\n \r\n\r\n \r\n \r\n
\r\n __________________
\r\n Erutangis a si tahw\r\n
\r\n \r\n \r\n\r\n \r\n\r\n \r\n \r\n
\r\n
\r\n \r\n \r\n Last edited by Loffen; 11-01-2004 at 10:57 AM.\r\n \r\n \r\n \r\n
\r\n \r\n \r\n\r\n
\r\n \r\n \r\n \r\n \r\n Reply With Quote\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n \r\n\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n'; pd[430878] = '\r\n\r\n \r\n\r\n
\r\n
\r\n
\r\n\r\n
\r\n \r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n \r\n \r\n\r\n
\r\n
\r\n  \r\n #2  \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n
\r\n \r\n Old\r\n \r\n 11-02-2004, 03:45 AM\r\n \r\n \r\n \r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n
\r\n \r\n John_0025\r\n John_0025 is offline\r\n\r\n\r\n
\r\n \r\n
\r\n
\r\n \r\n Thanks John!
\r\n
\r\nI peeked into the site already befor i posted, but i couldnt find anything i could use. I figured i can just use normal Split() function. This will be more code, but i think it will be easier to read.
\r\n
\r\n-' + '- Loffen\r\n
\r\n
\r\n \r\n
\r\n \r\n\r\n \r\n \r\n\r\n \r\n \r\n
\r\n __________________
\r\n Erutangis a si tahw\r\n
\r\n \r\n \r\n\r\n \r\n\r\n \r\n\r\n
\r\n \r\n \r\n \r\n \r\n Reply With Quote\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n \r\n\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n'; // next/previous post info pn[430829] = "430889,430878"; pn[0] = ",430829"; pn[430878] = "430829,430889"; pn[430889] = "430878,430829"; // cached usernames pu[0] = guestphrase; pu[34138] = "Loffen"; pu[35515] = "John_0025"; // -->
Prev Previous Post   Next Post Next
  #1  
Old 11-01-2004, 09:46 AM
Loffen's Avatar
Loffen Loffen is offline
Regular

Preferred language:
VB.NET
 
Join Date: Mar 2004
Location: Akershus, Norway
Posts: 51
Loffen is on a distinguished road
Default Regular Expression N00bie needs help :P

I am actually coding a map-loader class for my game. In the beginning the map format was quite simple, and i could just read line after line and put things together. Now, my mapformat is getting more complicated, and its much easier to make the whole thing crash. I have done some PHP and i know what regular expressions are, but i never bothered to learn them (mostly because i never needed them), but i think thats the thing i have to use..

My maps are separated into four sections. Config, Terrain data, Object data and Trigger data. I want to read the whole file, then split it up using reg expr. To clearify this i'll make an example:

The map:
Code:
[MAP_CONFIG:
map_name=Testmap
map_tileset=Default
]
[MAP_TERRAIN_DATA:
0;1;0;1;0;1;0;1;
0;1;0;1;0;1;0;1;
0;1;0;1;0;1;0;1;
0;1;0;1;0;1;0;1;
]
[MAP_OBJECT_DATA:
tree{pos=2,2;}
tree{pos=6,3;}
]
[MAP_TRIGGER_DATA:
hurt{pos=0,0;dmgamount=10;}
]
Here i'd like to separate the config, terrain data etc, like this:

ConfigVar =
Code:
map_name=Testmap
map_tileset=Default
TerrainDataVar =
Code:
0;1;0;1;0;1;0;1;
0;1;0;1;0;1;0;1;
0;1;0;1;0;1;0;1;
0;1;0;1;0;1;0;1;
etc...

I really have no ideas how to do this. If you know some good tutorials, please post them here. Suggestions?? I dont care if i have to change the map format a little...

-- Loffen
__________________
Erutangis a si tahw

Last edited by Loffen; 11-01-2004 at 10:57 AM.
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help w/ this Regular Expression reveilleboy Regular Expressions 1 09-21-2004 05:52 AM
Regular Expression Help please burak Regular Expressions 3 04-11-2004 04:24 PM
Regular Expression help Deepfreezed Regular Expressions 4 02-06-2004 12:55 PM
regular expression justplainsoccer Regular Expressions 0 12-21-2003 01:45 PM
Regular Expression Help Wjousts Regular Expressions 2 09-24-2003 07:47 PM

Advertisement:

Powered by liquidweb