Regular expressions are your friend

I just wanted to replace several but not all .bmp textures with jpegs. Started editing the .xml file. Wait! Too tired to type, lets quickly write a regex: Find {"gamedata\\levels\\level02\\textures\\}{.*}{bmp"} and replace with \1\2jpg". Result:

Doh! I would have typed a lot for this doing it manually.

five comments, already:

just one tiny question: is it necessary to use two groups? (regular expressions for DOS-style paths in C/C++/... are a bit annoying, as backslashes quadruple, like in “C:\\Windows”;).
bertl - 24 10 05 - 09:44

hey, somehow my backslashes have gone away…
bertl - 24 10 05 - 18:09

For Windows you do not have to use the backslash you can the forward slash for folder and file paths instead so you do not have to double up the back slashes
TSM - 24 10 05 - 18:15

maybe the way I did the regex is not the simplest way but at least it works.. :)
niko - 24 10 05 - 20:58

while this is true it is hard to get any standard program to list files with forward slashes instead of backslashes (and users also find this pretty strange typically).
bertl - 25 10 05 - 10:12


Displayed name:  
Remember personal info?
yes
no
Website (optional):
Enter "layered" (antispam):
Comment:Emoticons / Textile

 


Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.
Note: If you type in your email adress above, it will be visible to other visitors, although it will be hidden for bots using javaScript.