JSFiddle - React, Tailwind, and code Playground

HTML

<div> The part number is [8F8S0JJ9]</div>
<div> The second part number is [V9S7D73]</div>

JavaScript

// Get the product number that lies between [ ] marks from all div elements
$("div").filter(function(index){
    return /\[.*\]/.test($(this).html());
}).each(function() { 
    var $finalstring = $(this).html().match(/\[.*\]/)[0];
    $(this).html($(this).html().replace(/\[.*\]/),"");
    $("<div></div>").insertAfter(this).append($finalstring);
});