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 9294913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:28:48+00:00 2026-06-18T21:28:48+00:00

Sorry if this question is a duplicate of another ones, I couldn’t find it

  • 0

Sorry if this question is a duplicate of another ones, I couldn’t find it :-/

Hey guys, I am guessing it’s a simple regexp question but help me out will you? Regexps are always look so complicated to me 🙂

in this example :

@2 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent sit
amet quam ante, sit amet consectetur ante. Ut non urna in quam
adipiscing consectetur et sed lorem. Donec venenatis vehicula
porttitor.

I want to convert @2 to

<a href="#2">@2</a>

but user may type it like “@2Lorem..” without space or it may be @38427. how can i grab ‘@’ symbol and numbers after it and convert to anchor?

Edit: and also @ may be in the middle of text it may not always be in beginning.

  • 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-06-18T21:28:50+00:00Added an answer on June 18, 2026 at 9:28 pm
    preg_replace('/@(\d+)/', '<a name="#$1">@$1</a>', $string)
    

    sample:

    php > $x = 'abc @234lorem def';
    php > echo preg_replace('/@(\d+)/', '<a name="#$1">@$1</a>', $x);
    abc <a name="#234">@234</a>lorem def
    
    \d - any digit
    + - one or more times
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if this question is duplicate, but I can't find the same solution. In
Sorry if this is a duplicate question...I've searched around and found similar advice but
I'm sorry if this is a duplicate, but the question search terms are pretty
Sorry if this question is very easy, but I can't find the answer anywhere.
Sorry, this is probably a duplicate question, but how can I iterate over a
I've been thinking of this question very long, but really couldn't find the answer
First of all sorry if this is a duplicate, I couldn't find any subject
I am sorry that I duplicate this question , but I don't have the
Sorry if this is a duplicate question but google isn't smart enough to understand
I'm sorry for posting a semi-duplicate, but I've stopped getting answers in another question

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.