Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7167405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:34:23+00:00 2026-05-28T14:34:23+00:00

I am really really bad at regular expression, I don’t know why but I

  • 0

I am really really bad at regular expression, I don’t know why but I can never really figure it out.

at the moment I use the following code to put an image in front of my first navigation item:

$nav_out = preg_replace('/<a([^>]*)>/', '<a$1><img src="http://myimage.gif" border="0" />', wp_nav_menu( array('theme_location'  => 'menu-1', 'echo' => 0, 'container'       => false )),1);
echo $nav_out;

However I need the image to be at the BACK of my first item. I tried a bunch of things but I just can’t get it to work 🙁

Can anybody help me out here?

Would be really really gratefull!

EDIT: I took some screenshots

my original one with the image at the front

$nav_out = preg_replace('/<a([^>]*)>/', '<a$1><img src="http://www.bimiii.com/myimg.gif" border="0" />',

sqfqsd

the suggestion made by marcio

$nav_out = preg_replace('/<a([^>]*)>/', '<img src="http://www.bimiii.com/myimg.gif" border="0" /><a$1>',

qsdfsd

and I know this one is wrong but I just wanted to show it anyway

$nav_out = preg_replace('</a>', '</a><img src="http://www.bimiii.com/myimg.gif" border="0" />', 

qsdfqsdfs

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:34:23+00:00Added an answer on May 28, 2026 at 2:34 pm

    The regex in this case is used to match any anchor tag and inject the image near the anchors in your menu. You can reposition the image just using CSS:

    #your-menu-container-selector ul li img {
      float:right;
    }
    

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yes, I know, I know, parsing HTML with regular expressions is very bad. But
I know this is really bad practice, but it's already been put in place
I am really bad explaining but I'll try. Suppose I have with the following
Good day! My regular expression is really bad and I would like to ask
I'm really bad with regular expressions - never had enough time to learn it
Hi guys I know that this is really bad idea but I want join
Maybe I'm having a really bad day, but could someone possibly help me to
If you've ever used SharePoint Designer, you'll know it's bad. Really bad. Is there
Is it generally a really bad idea to not use the built-in asp.net membership
I'm really bad with html/css, so I'm just wondering if I can get your

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.