@@ -125,7 +125,6 @@ const Br = 0x202
125125var (
126126 deathRegex = regexp .MustCompile (`<td.*>(.*)<\/td><td>(.*) at Level ([0-9]+) by (.*).<\/td>` )
127127 summonRegex = regexp .MustCompile (`(an? .+) of ([^<]+)` )
128- accountBadgesRegex = regexp .MustCompile (`\(this\), '(.*)', '(.*)',.*\).*src="(.*)" alt=.*` )
129128 titleRegex = regexp .MustCompile (`(.*) \(([0-9]+).*` )
130129 characterInfoRegex = regexp .MustCompile (`<td.*<nobr>[0-9]+\..(.*)<\/nobr><\/td><td.*><nobr>(.*)<\/nobr><\/td><td style="width: 70%">(.*)<\/td><td.*` )
131130)
@@ -293,12 +292,37 @@ func TibiaCharactersCharacterImpl(BoxContentHTML string) (*CharacterResponse, er
293292
294293 // prevent failure of regex that parses account badges
295294 if CharacterListHTML != "There are no account badges set to be displayed for this character." {
296- subma1 := accountBadgesRegex .FindAllStringSubmatch (CharacterListHTML , - 1 )
295+ const (
296+ nameIndexer = `alt="`
297+ iconIndexer = `img src="`
298+ descIndexer = `', '`
299+ )
300+
301+ nameIdx := strings .Index (
302+ CharacterListHTML , nameIndexer ,
303+ ) + len (nameIndexer )
304+ endNameIdx := strings .Index (
305+ CharacterListHTML [nameIdx :], `"` ,
306+ ) + nameIdx
307+
308+ iconIdx := strings .Index (
309+ CharacterListHTML , iconIndexer ,
310+ ) + len (iconIndexer )
311+ endIconIdx := strings .Index (
312+ CharacterListHTML [iconIdx :], `"` ,
313+ ) + iconIdx
314+
315+ descIdx := strings .Index (
316+ CharacterListHTML , descIndexer ,
317+ ) + len (descIndexer )
318+ endDescIdx := strings .Index (
319+ CharacterListHTML [descIdx :], descIndexer ,
320+ ) + descIdx
297321
298322 AccountBadgesData = append (AccountBadgesData , AccountBadges {
299- Name : subma1 [ 0 ][ 1 ],
300- IconURL : subma1 [ 0 ][ 3 ],
301- Description : subma1 [ 0 ][ 2 ],
323+ Name : CharacterListHTML [ nameIdx : endNameIdx ],
324+ IconURL : CharacterListHTML [ iconIdx : endIconIdx ],
325+ Description : CharacterListHTML [ descIdx : endDescIdx ],
302326 })
303327 }
304328
0 commit comments