M
M
Mikhail Pakhmutov2013-12-17 19:52:56
JavaScript
Mikhail Pakhmutov, 2013-12-17 19:52:56

Javascript filtering repeated tags

Hello. I'm trying to assemble a wysiwyg editor for myself and, for the purity of the generated code, I generate the insertion of tags manually. I don't know how to filter out extra tags in this situation:

<b>Просто знать шаги <b>недостаточно</b>. Надо <i>чувствовать</i> музыку.</b>

<b></b>Here, around the word "not enough" are superfluous . How can this be filtered out?
Z.Y. I almost forgot, I don't use frameworks.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stanislav Skobelkin, 2013-12-17
@Slko

Dơ͖̦̖̺̬͚͓̐͋ͭп̲͍͈o̳̘͉̤͑l̴͓̞̺̯̫͚ͣ̃̓ͮ̀̈́н̞͕̲̓͊ͬͬ̈́͟ю̽̇̓ͤͮͨ ̜̳͎͕̬̎̃о̢͌mlv͛͛т . If you use the regular ID for HTM L, then you will need to be a throat .L͉͇͊̌͋͌̓̾͛̚ ͉̹̣ͭ̑ͪ͜Ḧ̵̵̸̢̡̢̡̢̛̛͔͓͇͔͓͇͇̤̤̥̰͇̤̤̥̰̭̦͍͚̯͈̗̺͖͕̳̩͍͔̫̭̣̜͉̼͊̈͊̓ͫͬ̓ͫͬͦͪ̏̽̏ͭ̒̒͐̌̌̌̐ͪ̉ͬ̔ͮ̓, Ch̵̜̺͙͇̫͕̳̋͋̅̔͠t̵̵̸̸̶̢̢̳̫̖̝͚͈̘̳̫̖̝͚͈̘̭̜̪̳̭̜̪̳̭̣͙̭̣͙̭̯͓̮͖͚͖̭̯͓̮͖͚͖̳͇̹̝͈̯̠͍̠͖̯̠͍̠͖̤͍͕͓͈̬̺͖̯̯ͬ͛ͤͥͬ͛ͤͥ̑͊ͭͭ̈ͥ̑͊ͭͭ̈ͥ̍̑̊̉ͣ̍̑̊̉ͣ̾ͪ̌̉̾ͪ̌̉ͯͯ͊̌ͦ̏ͤ̾ͬ̾ͬ͗̓ͧ̒̋ͭ̒̋ͭͧͤ͛ͪ͛ͪͣͨͯ̍̒͒̑̕̕͘͘͡͡͏͎̭̪̬ͣͨͯ̍̒͒̑͡͏̷͎̭̪̬ͤͣͦͪ͑͟҉̴̵̢̣͔͉̦̠̝̯̟̰̦̜̯͈̤̝̗̞̦̜̯͈̤̝̗̞̣͍͉͖̪͇̜̫͇̯̝͉͎̖̳͕̣͎͎̖̳͕̣͎ͭ͐͛͛̏̏̽̋͊̍ͤͣͦͤͣͦ̆̆͑ͮ̍ͬ̆͋̈͋ͬ̆͋̈͋͟͟͞͠ ̴̸̧̥̘̟͍̓ͫ͒͊͌̓̐̊̈͛͋ͭ̔҉̴̸͓͚͖̙̥̦̥̙͙̟̮̣̦̫̐̊̈͛͋ͭ̔҉̶̨͓͚͖̙̥̦̥̙͙̟̮̣̦̫̝̭͎͔̪̼̳̯̳̼̭͍̗̣̮͖̯̠̦͉̺͍͕͕̮̼͍͚̟̹̹̌̓͆ͣ̍͗ͩͯ̏ͫ̍̌̑ͣͤ̔̌̊͌̌ͣ̈̿̄͋̔͒͒̊͊̐̄ͬͮͣ̌͆̓̒̏̄̈̓͗̆̌̽̈̆̒ͬ̚̕̕͟͞͡͞͞҉̸̴̴̶̡̧̡̡̡̡̙͇̝͓̼̦̭͓̠͚̰͙̯̖̹̣̦͎͚̣͔̤͉̞̠̞̦̞̮͍̭̹̮̘̹̮͍̩̼͓̠̥̳̜̤̣̼̫͓̠̥̳̜̤̣̼̫̪̘̖͇̰̠͔̻̰̳̩̟̪̘̖͇̰̠͔̻̰̳̩̟̳̦̺̫̄ͭ̏̉͑ͭ̾͆ͫ͐̍̄̉ͨͬ̔ͣͮͨ̐͊͆ͮ͐̿̓ͯ̓ͯͤ̾̈ͥ̈ͦ̑͑ͫͥ͛ͤͨ̐͋͋̅ͬ͊̈ͦ̑͑ͫͥ͛ͤͨ̐͋͋̅ͬ͊ͧ̑̈ͫͬ̉̏̾ͣ͌̔ͤͧ̽͗͋ͮͧ̑̈ͫͬ̉̏̾ͣ͌̔ͤͧ̽͗͋ͮ̾͗ͧ̾̓͊ͤ̊̒̑̚̕̕͢͜͟͡͡͝҉̦̖̟̺͕͔͖͍͕̰̥̭͚̑͜͝҉̦̖̟̺͕͔͖͍͕̰̥̭͚͜͝
. _

S
Sergey Melnikov, 2013-12-17
@mlnkv

use a regular expression, but you will have to rack your brains)

var str = "<b>Просто знать шаги <b>недостаточно</b>. Надо <i>чувствовать</i> музыку.</b>";
str.replace(/<b>(.+)<b>(.+)<\/b>(.+)<\/b>/gi, "<b>$1$2$3</b>");

x something like this, but it's very rude, you need to read regular expressions and write correctly

M
Mikhail Pakhmutov, 2013-12-18
@ARCHANG3L

Slko, your answer is not displayed correctly, could you write again?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question