I need to convert some HTML content to UBB code, for instance replacing the < >
signs by square brackets [ ]
.
There als may be an ordered list <ol>
tag with a start=
attribute specifying the kind of marker.
const str = `<b>Something</b> is going on.<br><i>But what?</i><br><br><ol start="3"><li>First</li><li>Second</li><li>Third</li></ol>`;
const regex = new RegExp(`<(\/?([bisu]|li|ul|ol|ol start="\d+"))>`);
let result = str.replace(/0/gi, '').match(regex);
This works as expected, but I’d like to remove the quotation marks, so the <ol start="3">
will become [ol start=3]
. I wonder if this is possible in the same regex.
You need to sign in to view this answers
Leave feedback about this