Как я могу обернуть текст внутри определенных символов с помощью HTML? [закрыто]Jquery

Программирование на jquery
Ответить
Гость
 Как я могу обернуть текст внутри определенных символов с помощью HTML? [закрыто]

Сообщение Гость »


I have an HTML output that contains hyphen and comma characters.

For example: regular text - bold text, another regular text - another bold text

What I need is to wrap the text after the hyphen with strong tags, up until the comma, and replace the commas with a br tag.

So the output should look like this:

regular text - bold text
another regular text - another bold text
The next code I used replaced the commas with 'br' tags but does not wrap the text after the hyphen with 'strong' tags:
$(document).ready(function() { $('p').each(function() { const text = $(this).text(); const formattedText = text.replace(/- (.*?)(?:\s*,|$)/g, '- $1$2').replace(/,/g, '
'); $(this).html(formattedText); }); });

Источник: https://stackoverflow.com/questions/781 ... -with-html
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Jquery»