In your first example, your regex is \s
, which will match a whitespace character. In the second example, you have \s*
, which will match zero or more whitespace characters. You’re probably looking for \s+
, one or more whitespace characters.
Related Posts:
- Insert Custom HTML After Shortcode
- How to apply content filter permanently?
- Why won’t my preg_replace work with content_save_pre?
- String regex match replace for role ‘contributor’ only
- Using preg_replace() with the_content filter
- Stripping URLs & Email from post submissions
- How to wrap pattern-matches from the_content in [wiki]-shortcode tags
- Add class to all parent elements inside the_content
- post->post_content filter
- How to reorder billing fields in WooCommerce Checkout template? [closed]
- How to add a custom CSS class to core blocks in Gutenberg editor?
- No filter of code on switch from html to visual editor, how?
- How to modify posts_where filter only for the search query
- Filter translations (gettext strings) on specific admin pages
- Filter hook before create order WooCommerce
- How to auto-translate custom user roles?
- Adding revision support to WooCommerce product content
- Changing text within the Block Editor
- add_filter for specific pages
- How to add attribute to output with wp_video_shortcode add_filter
- Change default settings used by gallery shortcode
- PHP5, Inheritance, Singleton – action & filter hook limitations
- Please explain me what the do_action does
- How Can I Have A URL Changed Based on the Originating URL?
- Is it possible to Hook/Filters Attachment Creation?
- Add ‘if exists’ to filter
- Change html structure of all img tags in WordPress
- how to remove filter from wordpress shortcode output
- Change email from and display name with a filter action
- How to check if “media_send_to_editor” is audio?
- Changing Order of Filters
- Please help me through this example with a filter to understand how they work
- Filter custom post types in archive
- WordPress tag cloud add more links
- How can I filter block registration based on post-type? (Block alignment settings)
- wp_insert_post_data filter not working correctly after upgrade to WordPress 5
- Yoast SEO hooks overriding themselves
- Passing variable from child theme to parent theme
- Question about how do wordpress filters/actions work
- How to center oEmbedded content
- Add Sortable Column For All Post Types
- How to take options from form fields and turn them in to links?
- When to use add_action when registering/enqueuing scripts
- How add a group by to the query used by the media library?
- add_filter(allowed_block_types) -> adding core/paragraph bugs Gutenberg editor
- How to properly modify WP Vary or any existing headers?
- How to remove medium size class in gravity form for input tag?
- Custom wp_query time filter on meta_value
- get post id within add_filter()
- Can I override the content array using the_posts filter?
- Media upload default title from file name
- Admin post list – adding an option to the date filter dropdown
- Use of comment_reply_link_args filter
- How to use do_shortcode_tag to modify the output of a shortcode?
- Shortcodes within the sidebar text/html widget: How to preserve the raw HTML output of the shortcode?
- Alter existing page contents based on url
- Error using wp_mail inside custom function
- How to include add_filter() in a condition based on $post data
- Admin: how to make a custom list filter button send GET queryvars
- Filter authors on meta value
- Override email_exists function
- Is this hook really deprecated? ( manage_{$taxonomy}_custom_column )
- arguments for comment_notification_text filter
- Add_filter rel=”prettyphoto” to WP3.4.1
- How can i filter wordpress users by custom feild?
- The gettext hook doesnt work on text with links
- How to filter the source URL of all images on every page
- auth_redirect() doesn’t send users to the page where they orginally tried to acces
- How to redirect a unique link based on login status
- “The editor has encountered an unexpected error” After add defer tag to java script
- Create different flavours of excerpt
- Is it possible to assign a css id to a row in plugins list table?
- How to bridge the gap between dynamic back-end data and front-end output?
- How to loop year & month condition together to filter correctly via AJAX?
- Why does wp_die() not work when inside a namespace?
- Apply pre_get_posts filter in a certain moment (just for a particular block of posts)
- Modify oembed code conditionally
- Set post featured image to author image
- How to Change the WordPress Locale with the ‘locale’ Filter?
- meta box loop problem with a search filter
- Prevent WordPress from putting around specific element
- Modify Default URL for /wp-includes/js/wp-emoji.js?ver=4.6.1
- List all image sizes still getting disabled sizes
- wp_editor customization
- What problems could happen if I replaced add_filter and add_action with the function calling
- posts_results filter function memory errors
- Adding to an array & passing it through do_action/apply_filters
- Is it possible to include the add_filter() function within a shortcode function
- Activate short codes for all post queries?
- Save something to global var in add_filter
- Loading a sidebar on an Ajax call
- the_excerpt() does not work with has_excerpt()?
- filter on the_content stopped working when I updated to WP 3.6.1
- Replace Paid Shipping Method With Free Shipping Method WooCommerce [duplicate]
- Wrapping Featured Image on Add/Edit Page in div?
- Clean/filter HTML inserted to post content by XML RPC
- how to localize the number of wordpress post views?
- Is it possible to make get variable out of filter in Class?
- How do you disable the verification process of user email changes?
- Modify the third (context) parameter in a filter?