$re = '/\G({+)([[:alnum:]]+)(}+)(Biography)+\n+|\v/mU';
$str = '{Witchking}Biography
{Witchking_desc}The Witch-King is the Lord of all Nazgûl, Sauron\'s most terrible servants. Once a great king of Men, his will is controlled through one of the nine Rings Of Power.\\n
{Witchking_effects_desc}Command +15\\nLoyalty +10\\nAuthority +15\\nGeneral\'s Hit Points +10\\nTroop Morale +20\\nAttack +100 \\nDefence +100
¬---------------------
{Aragorn}Biography
{Aragorn_desc}After his father Arathorn was killed by orcs, Aragorn was fostered in Rivendell by Elrond. Aragorn thereafter assumed his proper role as the sixteenth Chieftain of the Dúnedain, the Rangers of the North, and went into the wild where live the remnants of his people. Though their kingdom was destroyed through civil and regional wars centuries before, the northern Dúnedain remain loyal to Aragorn and committed to the fight against the shadow.\\n
{Aragorn_effects_desc}Command +3\\nLoyalty +6\\nAuthority +3\\nTroop Morale +2\\nGeneral\'s Hit Points +6\\nPersonal Security +2
¬---------------------
{Aragorn2}Biography
{Aragorn2_desc}After his father Arathorn was killed by orcs, Aragorn was fostered in Rivendell by Elrond. Aragorn thereafter assumed his proper role as the sixteenth Chieftain of the Dúnedain, the Rangers of the North, and went into the wild, where live the remnants of his people, whose kingdom had been destroyed through civil and regional wars centuries before.\\n
{Aragorn2_effects_desc}General\'s Hit Points +10\\nCommand +12\\nLoyalty +6\\nAuthority +31\\nAttack +40\\nTroop Morale +20\\nDefence +40
¬---------------------
{Elessar}Biography
{Elessar_desc}After his father Arathorn was killed by orcs, Aragorn was fostered in Rivendell by Elrond. Aragorn thereafter assumed his proper role as the sixteenth Chieftain of the Dúnedain, the Rangers of the North, and went into the wild where live the remnants of his people. Though their kingdom was destroyed through civil and regional wars centuries before, the northern Dúnedain remain loyal to Aragorn and committed to the fight against the shadow.\\n
{Elessar_effects_desc}Command +4\\nLoyalty +5\\nAuthority +3\\nTroop Morale +2\\nGeneral\'s Hit Points +6\\nPersonal Security +2
¬---------------------
{Halbarad}Biography
{Halbarad_desc}Halbarad is a Ranger of the North, and is second-in-command of the Dúnedain behind Aragorn. As such, he acts in the capacity of the "Steward of the North" and as leader of the Grey Company. Halbarad is among the Rangers who guard the Shire. He has said of the Hobbits "A little people but of Great worth are the Shire-folk. Little do they know of our long labour for the safe-keeping of their borders. As a kinsman of Aragorn, Halbarad is entrusted with the King\'s Standard on the battlefield.\\n
{Halbarad_effects_desc}Command +2\\nGeneral\'s Hit Points +3\\nRespect +3\\nLoyalty +3\\nPersonal Security +2\\nTroop Morale +2
{Halbarad_epithet_desc}of the North
¬---------------------
{Legolas}Biography
{Legolas_desc}Legolas is the son of Thranduil, King of the Woodland Realm of Northern Mirkwood. Although he lives among the Silvan Elves, Legolas is not strictly Silvan himself. His father Thranduil originally came from Lindon; he and his son are actually Sindar, or "Grey Elves". A small minority of Sindar rules the predominantly Silvan Woodland Realm.\\n
{Legolas_effects_desc}Command +10\\nGeneral\'s Hit Points +6\\nPersonal Security +2\\nLine of Sight +3\\nMovement Points +4\\nAmbush +3\\nLoyalty +6
¬---------------------
{Gimli}Biography
{Gimli_desc}Gimli is the son of Glóin, one of the former companions of the hobbit Bilbo Baggins. He is a remote descendant of Durin the Deathless, chief of the Seven Fathers of the Dwarves and ancestor of the Dwarven people to which Gimli belongs, the Longbeards. Gimli is of the royal line, but not close to the succession; he is the third cousin once removed of Dáin II Ironfoot, king of Durin\'s Folk, and the first cousin once removed of Balin, who was Lord of Moria for a short time.\\n
{Gimli_effects_desc}Command +2\\nLoyalty +5\\nGeneral\'s Hit Points +6\\nPersonal Security +2\\nSiege Attack +2\\nAuthority +1
¬---------------------
{Gandalf}Biography
{Gandalf_desc}Gandalf the Grey was the last of the Istari to arrive in Middle-earth, landing in Mithlond. He is the oldest and least in stature of them, but on their first meeting in the Havens, Círdan the Shipwright felt that he had the highest inner greatness and gave him Narya, the Ring of Fire. Gandalf hides the ring well, and it is not widely known that he, and not Círdan, is the holder of the third of the Elven-rings.\\n
{Gandalf_effects_desc}Command +3\\nGeneral\'s Hit Points +8\\nPersonal Security +2\\nRespect +4\\nLoyalty +5\\nAuthority +2\\nAttack +2\\nDefence +2
¬---------------------
{Thengel}Biography
{Thengel_desc}Thengel the Thrice-renowned is the sixteenth King of Rohan. He is the only son of Fengel, and became king after the death of his father in T.A. 2953. Thengel left Rohan in his youth and went to live with his mother\'s family in Gondor. There he learned Sindarin which is is the daily tongue in his house, together with Westron, the common speech.\\n
{Thengel_effects_desc}Command +2\\nGeneral\'s Hit Points +4\\nPersonal Security +1\\nRespect +3\\nLoyalty +5\\nAuthority +2
¬---------------------
{Theoden}Biography
{Theoden_desc}Théoden is the oldest son of Thengel, a member of the House of Éorl and heir to the throne of Rohan. He speaks Sindarin and Westron rather than Rohirric, and in his youth spent time in Gondor.\\n
{Theoden_effects_desc}Command +3\\nGeneral\'s Hit Points +5\\nPersonal Security +1\\nRespect +2\\nLoyalty +5\\nAuthority +2
¬---------------------
{Eomer}Biography
{Eomer_desc}Eomer, son of Eomund, loyal above all to the people of Rohan.\\n
{Eomer_effects_desc}General\'s Hit Points +5\\nCommand +2\\nRespect +2\\nLoyalty +5\\nAuthority +1
¬---------------------
{Lurtz}Biography
{Lurtz_desc}Lurtz is the first commander of Isengard\'s armies. He is highly trusted by Saruman, and thus inspires his troops to do Saruman\'s bidding; whatever that might be. Let no man, elf, dwarf, or even another orc stand in the way of Saruman\'s will whilst Lurtz is their commander.\\n
{Lurtz_effects_desc}Command +2\\nGeneral\'s Hit Points +5\\nPersonal Security +1\\nTroop Morale +2\\nMovement Points +3\\nLoyalty +3\\nAuthority +2
¬---------------------
{Ugluk}Biography
{Ugluk_desc}Uglúk is the first commander of Isengard\'s armies. He is highly trusted by Saruman and Sauron, and ruthlessly enforces Saruman\'s orders - beheading another orc to prevent Saruman\'s orders being disobeyed.\\n
{Ugluk_effects_desc}Command +1\\nGeneral\'s Hit Points +4\\nPersonal Security +1\\nTroop Morale +1\\nMovement Points +2\\nLoyalty +2\\nAuthority +1
¬---------------------
{Saruman}Biography
{Saruman_desc}Saruman the White was once the Chief of the Order of Wizards, whose mission was to help the free peoples of Middle-earth in their struggle against Sauron without seeking domination or power for themselves. He is wise and powerful, but he became resentful and jealous of Gandalf and became corrupted by desire for the One Ring.
{Saruman_effects_desc}Command +3\\nGeneral\'s Hit Points +8\\nPersonal Security +2\\nRespect +3\\nAuthority +2\\nAttack +2\\nDefence +2
¬---------------------
{grima_diplomat}Biography
{grima_diplomat_desc}Nothing is known about Grima\'s early life. Grima is the son of Galmod and he has a pale face and dark, heavy-lidded eyes. He is a henchman of Saruman and serves as an archetypal sycophant, flatterer, liar, and manipulator.\\n
{grima_diplomat_effects_desc}Influence +1\\nMovement Points -25% (reduces the distance this agent can march)
{grima_diplomat_epithet_desc}Wormtongue
¬---------------------
{Ecthelion}Biography
{Ecthelion_desc}Ecthelion II is the twenty-fifth ruling Steward of Gondor. He succeeded his father Turgon at his death in T.A. 2953. In the beginning of his rule Orodruin, also known as Mount Doom, burst into flame and the few remaining people of Ithilien fled over the Anduin.\\n
{Ecthelion_effects_desc}Command +2\\nGeneral\'s Hit Points +4\\nPersonal Security +1\\nRespect +3\\nAuthority +2\\nLoyalty +5
¬---------------------
{Denethor}Biography
{Denethor_desc}Denethor II is the twenty-sixth ruling Steward of Gondor. He succeeded his father Ecthelion II at his death in T.A. 2984. Denethor appears noble and powerful, and rivals even the lordliness of Gandalf. He is proud, tall, wise, far-sighted, and valiant; \'more kingly\' than many of his predecessors. He proved a masterful lord and a great ruler, seeing to all things large and small under his command.\\n
{Denethor_effects_desc}Command +2\\nGeneral\'s Hit Points +3\\nPersonal Security +1\\nRespect +3\\nAuthority +2\\nLoyalty +5
¬---------------------
{Elrond}Biography
{Elrond_desc}Elrond is Lord of Rivendell, one of the mighty rulers of old that remained in Middle-earth. His name means "Vault of Stars", "Star-dome" or "Elf of the Cave". He is the son of Eärendil and Elwing, and a great-grandson of Lúthien, born in Beleriand in the First Age, making him well over 6,000 years old. Elrond\'s twin brother was Elros Tar-Minyatur, the first High King of Númenor.\\n
{Elrond_effects_desc}Command +2\\nGeneral\'s Hit Points +8\\nPersonal Security +2\\nRespect +3\\nAuthority +2\\nLoyalty +5
¬---------------------
{Elladan}Biography
{Elladan_desc}Elladan and his twin brother Elrohir are the children of Celebrían and Elrond. Dark-haired and grey-eyed, only those that know them well can tell them apart. The first of the twins was named Elladan, ("Elf-Man") as a token of his ancestry; he was descended not only from the royal houses of the Noldor and the Sindar, but also from the Houses of Hador and Bëor of the Edain.\\n
{Elladan_effects_desc}Command +1\\nGeneral\'s Hit Points +5\\nPersonal Security +1\\nRespect +2\\nAuthority +1\\nLoyalty +3
¬---------------------
{Elrohir}Biography
{Elrohir_desc}Elrohir and his twin brother Elladan are the children of Celebrían and Elrond. Dark-haired and grey-eyed, only those that know them well can tell them apart. He was descended not only from the royal houses of the Noldor and the Sindar, but also from the Houses of Hador and Bëor of the Edain.\\n
{Elrohir_effects_desc}General\'s Hit Points +5\\nPersonal Security +1\\nRespect +2\\nAuthority +1\\nLoyalty +2
¬---------------------
{Cirdan}Biography
{Cirdan_desc}Círdan is a Telerin Elf, a great mariner and shipwright, and lord of Mithlond. He was the bearer of the Great Ring Narya, which he in turn gave to Gandalf. He has a beard, which is rare for Elves, and his \'true\' name, according to the tradition among the Sindar of Doriath, is Nōwē in the form it had in the original tongue of the Elves.\\nDuring the War of Wrath, the land of Beleriand sank beneath the ocean. However, because of Círdan\'s mariners, many survived and sailed to the new shores of Middle-earth, where they would come to form the havens of Lindon and Mithlond.\\n
{Cirdan_effects_desc}General\'s Hit Points +6\\nRespect +2\\nAuthority +1\\nLoyalty +2
¬---------------------
{Glorfindel}Biography
{Glorfindel_desc}Glorfindel is one of the mightiest Elves of Middle-earth in the Third Age. He is distinctive because of his return to Middle-earth after death as an emissary of the Valar, on a similar mission to the Istari who were to come several thousand years later. His parentage is unknown.\\n
{Glorfindel_effects_desc}Command +2\\nGeneral\'s Hit Points +8\\nPersonal Security +2, Respect +3\\nAuthority +2\\nLoyalty +4
¬---------------------
{Thranduil}Biography
{Thranduil_desc}Thranduil the Elvenking is a Sindarin Elf and King of the Silvan Elves in the northern part of Mirkwood. He is the son of Oropher and father of Legolas Greenleaf. Thranduil is one of many Sindar who travelled eastward from Lindon at the beginning of the Second Age. He eventually ended up in Greenwood the Great, where Silvan Elves of Nandorin descent lived. His father Oropher was taken by them as lord and founded the Woodland Realm.\\n
{Thranduil_effects_desc}Command +2\\nGeneral\'s Hit Points +8\\nPersonal Security +1\\nRespect +3\\nAuthority +2\\nLoyalty +5
¬---------------------
{Celeborn}Biography
{Celeborn_desc}Celeborn is the Elven husband of Galadriel, Lord of the Galadhrim, and, along with Galadriel, co-ruler of Lothlórien. He is the father of Celebrían, the wife of Elrond, and thus the grandfather of Arwen Evenstar and her older brothers Elladan and Elrohir.\\n
{Celeborn_effects_desc}Command +2\\nGeneral\'s Hit Points +6\\nPersonal Security +1\\nRespect +3\\nAuthority +2\\nLoyalty +3
¬---------------------
{Haldir}Biography
{Haldir_desc}Haldir is a Silvan Elf of Lothlórien and a marchwarden who guards the forest\'s northern borders. Haldir and his companions live on platforms in the trees and he is one of the few Elves of Lórien who can speak Westron.\\n
{Haldir_effects_desc}Command +2\\nGeneral\'s Hit Points +6\\nPersonal Security +1\\nRespect +2\\nAuthority +1\\nLoyalty +4
¬---------------------
{Dain}Biography
{Dain_desc}Dáin II or Dáin Ironfoot is the son of Náin and grandson of Grór, the youngest son of King Dáin I, and is King under the Mountain and King of Durin\'s folk. Dáin fought in the War of the Dwarves and Orcs, but his only recorded deeds are at the Battle of Azanulbizar.\\n
{Dain_effects_desc}Command +2\\nGeneral\'s Hit Points +5\\nPersonal Security +1\\nRespect +3\\nAuthority +2\\nLoyalty +5
¬---------------------
{Bard}Biography
{Bard_desc}Bard of Esgaroth is a skilled archer and the son of Girion, the last king of old Dale. Bard was able to slay the Dragon Smaug with a single arrow after a tip from the old thrush revealed an unarmoured spot on the Dragon\'s underside. Because of his miraculous shot he was given the epithet "the Bowman". After the rebuilding of Esgaroth, Bard became the first King of the restored Kingdom of Dale.\\n
{Bard_effects_desc}Command +1\\nGeneral\'s Hit Points +4\\nPersonal Security +1\\nRespect +3\\nAuthority +2\\nLoyalty +5
¬---------------------
{Boromir}Biography
{Boromir_desc}Boromir is the brother of Faramir and the eldest son of Denethor II, the ruling Steward of Gondor. He is honourable and noble; he believes passionately in the greatness of his kingdom and would defend its people to the very last. Boromir\'s great stamina and physical strength, together with a forceful and commanding personality, make him a widely-admired commander in Gondor\'s army. He was made Captain of the White Tower and quickly became Captain-General; he also bears the title High Warden of the White Tower.\\n
{Boromir_effects_desc}Command +2\\nGeneral\'s Hit Points +5\\nPersonal Security +1\\nRespect +3\\nAuthority +2\\nLoyalty +5
¬---------------------
{Faramir}Biography
{Faramir_desc}Faramir is the younger brother of Boromir and second son of Denethor II, the Steward of Gondor. He is gentle in bearing, a lover of lore and of music, and thus his courage is judged as less than his brother\'s despite his great nobility and capable leadership. He has great skill-at-arms and is one of the best human archers in Middle-earth; he is a fitting Captain-general of the Rangers of Ithilien.\\n
{Faramir_effects_desc}Command +2\\nGeneral\'s Hit Points +4\\nPersonal Security +2\\nRespect +4\\nAuthority +1\\nLoyalty +4
¬---------------------
{Ents}Biography
{Ents_desc}Treebeard or (Sindarin) Fangorn is the oldest of the Ents, a tree-like being who is a sort of shepherd of trees. Very tall and stiff-limbed, with bark-like skin and leafy hair he lives in Fangorn forest, which is named after him. Like most Ents, Treebeard takes a long time to make up his mind and he is probably the oldest being in all of Middle-earth.\\n
{Ents_effects_desc}Command +2\\nGeneral\'s Hit Points +2\\nPersonal Security +3\\nMovement Points -15%\\nDefence +2\\nAmbush +3\\nRespect +5\\nAuthority +4\\nLoyalty +5';
$subst = "\1\2\3\2\n";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php