Get partial class name and text inside div using regex
Get partial class name and text inside div using regex I need to get two values from this HTML, which is either an error or a success from toast-* , and also get the value inside the toast-message : toast-* toast-message <div class="toast toast-error" style=""> <div class="toast-message">You have failed.</div> </div> <div class="toast toast-success" style=""> <div class="toast-message">You have succeed. </div> The div elements only show once at a single time, which can be either error or success. div Is there any way I can use regex, so I can extract the value within array so it either: ['success', 'You have succeed.'] or ['error', 'You have failed.'] Any help would be greatly appreciated. Thanks! Why do you want to use a regular expression here? Do you have a reference to the elements? – CertainP...