Fix #183: Deck parser doesn't too eagerly replace ampersands.

This commit is contained in:
arxanas 2014-07-19 14:47:19 -04:00
parent 88e6d0d3eb
commit 0eb97c91b3

View file

@ -563,9 +563,20 @@ bool DeckList::loadFromStream_Plain(QTextStream &in)
cardName.replace(rx, "AE");
rx.setPattern("^Aether");
cardName.replace(rx, "AEther");
rx.setPattern("\\s*[&|/]{1,2}\\s*");
rx.setPattern("\\s*[|/]{1,2}\\s*");
cardName.replace(rx, " // ");
// Replace only if the ampersand is preceded by a non-capital letter,
// as would happen with acronyms. So 'Fire & Ice' is replaced but not
// 'R&D' or 'R & D'.
//
// Qt regexes don't support lookbehind so we capture and replace
// instead.
rx.setPattern("([^A-Z])\\s*&\\s*");
if (rx.indexIn(cardName) != -1) {
cardName.replace(rx, QString("%1 // ").arg(rx.cap(1)));
}
++okRows;
new DecklistCardNode(cardName, number, zone);
}