Rather than messing with regex, you might consider using a user-defined excerpt (i.e. a manual excerpt, which retains HTML tags, rather than relying solely on the automatic excerpt, which strips HTML tags.
Depending on your specific use case, using the manual excerpt for displaying HTML-formatted excerpts is usually an easier approach.
Related Posts:
- Using wp_trim_excerpt to get the_excerpt() outside the loop
- How can i limit the character length in excerpt? [duplicate]
- How to include line-breaks in the_excerpt?
- How to get the unfiltered excerpt, without […] or auto-excerpting
- Remove “Continue Reading” Link From the Teaser Excerpt Only
- Modify youtube video size on one page and show another size on different page
- Issue with enabling formatting in excerpts in WordPress
- Excerpt Word Count
- Limit the_excerpt in the first point (.) of the sentence
- How to show only manual / custom excerpts?
- Excerpts that don’t truncate words
- Spacing within the excerpt
- “Read more” link doesn’t show up when the post length is under the excerpt length
- How to remove “Read on” content in the_excerpt?
- the_excerpt Read More Filter
- How to get the excerpts of all children pages
- Custom excerpt showing first paragraph (with HTML formatting)
- Empty excerpt using wp_get_recent_posts
- Different ‘read more’ links
- The excerpt: Display text OR image OR video
- How to display only the excerpt in the blog/posts page with Gutenberg?
- Read More for Excerpt not working
- adjust the_excerpt based on template page
- First letter cutting off in excerpt
- How to correctly limit the content and strip HTML?
- How to display links in excerpt? [duplicate]
- Getting the_excerpt to link to child pages [closed]
- Getting first 20 words without excerpt
- Change excerpt length of first post
- Display oEmbed in the_excerpt
- Auto Populate Excerpt Field
- Show validation warning if no Excerpt is added
- Line in excerpt and max 5 lines
- Include post title in readmore link?
- Excerpt using Read More Tag
- How to show post content before read more tag (excerpt) for password protected posts?
- How to apply excerpt length only on front end?
- get_the_excerpt() issues – returns the excerpt twice or not at all?
- Excerpt content
- Show excerpts of posts on P2 Home page
- How to change the length of excerpt() method?
- Removing h3s in excerpt output?
- get_the_excerpt without images
- How to wrap “Read More” link in a DIV tag?
- Automatic excerpts
- how to get excerpt without p html tag from wordpress post
- How to properly show the Excerpt only if it exists?
- The excerpt doesn’t add Read more
- Text with special class as excerpt (or exclude special class)
- Display post excerpt instead of content, if available
- Show Excerpts In Twenty Eleven Theme
- How do you edit the html of teaser excerpts
- Add custom read more to the_excerpt and
- Remove [ and ] from excerpt
- Is it possible to use words as starting and ending points of excerpt parameters?
- PHP Code in excerpt?
- Split the_content into two parts
- How to replace get_the_excerpt with first N words of post article while stripping html
- How to edit a typo in excerpt?
- My post excerpt does not work
- The excerpt suffix won’t go away
- Adding […] string for a custom excerpt function
- Replace text in excerpt
- How to achieve two different excerpt types on one WordPress site?
- Removing the […] from the excerpt returned by get_the_excerpt() only in some places
- Modify excerpt link
- Excerpt not alway available
- Continuum Theme – Excerpt length
- Prevent Advanced Excerpt from Being Called
- Reblog WordPress to another WordPress?
- How to enable excerpts just on the “Posts page”
- get_the_excerpt only returns one excerpt
- Excerpts not showing
- Keep excerpt from stripping URLs and enable autoembed for youtube ONLY?
- Excerpt being limited too early
- Help needed using wp_trim_words
- Excerpt of certain page to display on home page
- get_the_excerpt adding unwanted links to output html
- Excerpt functions is removing the forward slash on the url
- the_excerpt() doesn’t return the Excerpt field content
- How to add a new line to an excerpt?
- Excerpt “Read More” link
- Force authors to use Manual Excerpt in WordPress and multiple Manual Excerpts
- 2 posts same excerpt?
- Excerpt displays the current page excerpt not one being pulled
- Trimming breaks up markup
- Edit the excerpt before it is shown
- WordPress excerpt with formatting and allowing selected tags
- Is there a html tag filter for the excerpt?
- Add rel=lightbox to custom string
- multiple excerpt length and styles
- WordPress Post Format If Statement?
- How to show excerpt field
- Get a raw value of excerpt
- Post content not showing
- Need to show post summary in sidebar
- Limited excerpt with readmore
- Setting post excerpt length in php wordpress code, Should will help to save DB size?
- Format main page post excerpt previews
- HTML in excerpt WordPress 6.2.2