Skip to content

Instantly share code, notes, and snippets.

@SelStrom
Last active September 16, 2016 16:29
Show Gist options
  • Save SelStrom/8de6837ab62fdb49e3bd18d14f8f6370 to your computer and use it in GitHub Desktop.
Save SelStrom/8de6837ab62fdb49e3bd18d14f8f6370 to your computer and use it in GitHub Desktop.
Regular expressions for converting a .fnt file in to .xml
fist line: <reg exp>
second lines : <
code
for
replasing
>
(?<!\.)(-?\d+(?:,?-?\d+)*)(?! Semi)(?!\.)
"$1"
([\s\S]+)
<?xml version="1.0"?>
<font>
$1
</font>
((?:info face.+)|(?:common .+))
<$1/>
(page id=.+)
<pages>
<$1/>
</pages>
((?:char id=.+)|(?:kerning fi.+))
<$1/>
(chars count=.+)([\s\S](?:\s+.?char id.+)+)
<$1>$2
</chars>
(kernings count=.+)([\s\S](?:\s+.?kerning fi.+)+)
<$1>$2
</kernings>
--------------------- or short form ----------------------------
(?<!\.)(-?\d+(?:,?-?\d+)*)(?! Semi)(?!\.)
"$1"
((?:char id=.+)|(?:kerning fi.+))
<$1/>
(info face.+)[\s\S](common .+)[\s\S](page id=.+)[\s\S](chars count=.+)([\s\S](?:\s*.?char id.+)+)[\s\S](kernings count=.+)([\s\S](?:\s*.?kerning fi.+)+)
<?xml version="1.0"?>
<font>
<$1/>
<$2/>
<pages>
<$3/>
</pages>
<$4>$5
</chars>
<$6>$7
</kernings>
</font>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment