diff --git a/src/flat_layout/flat_html.ts b/src/flat_layout/flat_html.ts
index 7627b63..7d11b40 100644
--- a/src/flat_layout/flat_html.ts
+++ b/src/flat_layout/flat_html.ts
@@ -24,7 +24,7 @@ export class FlatHTML extends FlatQuestion {
}
private static correctHtmlRules: [{ searchRegExp: RegExp, replaceString: string }] = [
- { searchRegExp: /(<\/?br\s*?\/?\s*?>\s*){2,}/, replaceString: '
' }
+ { searchRegExp: /(<\/?br\s*?\/?\s*?>\s*){2,}/g, replaceString: '
' }
]
protected correctHtml(html: string): string {
FlatHTML.correctHtmlRules.forEach((rule) => {
diff --git a/tests/flat_html.test.ts b/tests/flat_html.test.ts
index 8d39541..051885c 100644
--- a/tests/flat_html.test.ts
+++ b/tests/flat_html.test.ts
@@ -86,6 +86,8 @@ test('Check correctHtml method with multiple br tags', async () => {
const htmlFlat = new FlatHTML(survey, new QuestionHtmlModel('q1'), controller);
expect(htmlFlat['correctHtml']('Test
')).toEqual('Test
');
expect(htmlFlat['correctHtml']('Test
')).toEqual('Test
');
+ expect(htmlFlat['correctHtml']('
Test
')).toEqual('
Test
');
+ expect(htmlFlat['correctHtml']('
Test
Test
')).toEqual('
Test
Test
');
expect(htmlFlat['correctHtml']('Test
')).toEqual('Test
');
expect(htmlFlat['correctHtml']('
Test
')).toEqual('
Test
');
expect(htmlFlat['correctHtml']('
')).toEqual('
');