I'm creating a read more function.* I want to split my html code at the point where <span id="more-NUMBER"></span> happens. Then I want to move the before and after sections.
The problem I'm running into is writing the regex in a way that can account for the numbers placed in the id. Here's what I'm starting with:
var text = jQuery('p').html().split('<span id="more-/\d+/"></span>');
text[0].appendTo('.red-text');
text[1].appendTo('.blue-text');
Here's a starter Fiddle: https://jsfiddle.net/samwisegrangee/r8c4urht/
*I had one that worked previously when our Wordpress site used a <!--more--> comment to create a read more. You can view that solution here: https://codepen.io/samwisegrangee/pen/aWGJOO
split('<span id="more-/\d+/"></span>');That's not a regEx.. it's just a string..split()happen regardless of the number in that string?