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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:26:21+00:00 2026-06-16T03:26:21+00:00

I notice a lot of code where people do something like: myClass.someMethod(something here, $1);

  • 0

I notice a lot of code where people do something like:

myClass.someMethod(something here, $1);

The $1 is picking up a value from “something here”?

What is this known as? I can’t seem to find it anywhere? But this step, process is used in cases with regex quite a bit..

  • 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-16T03:26:22+00:00Added an answer on June 16, 2026 at 3:26 am

    You’ll often see this in regular expressions where $1 represents a capture group that you’re carrying over into the new value.

    For example, suppose we’re building a tweet-parser for our website. We want to find @ references in the tweet, and convert them into links to those particular accounts:

    // Our Tweet
    $t = "I am @jonathansampson, and I work with @appendTo.";
    
    // Find every occurence of @something, capture 'something'
    echo preg_replace("/@([a-z]+)/i", "<a href='http://twitter.com/$1'>$0</a>", $t);
    

    Note here that we’re matching every occurrence of @something, but we’re wrapping the username portion in ( and ) so that we can handle it individually in our replacement text. The entire pattern is represented by $0, which will hold the value in its entirety from @ to the last char in the username.

    The same is true for JavaScript:

    var tweet = "I am @jonathansampson, and I work with @appendTo.",
        patrn = /@([a-z]+)/gi,
        links = tweet.replace(patrn, "<a href='http://twitter.com/$1'>$&</a>");
    

    The variable links now contains the value:

    console.log(links);
    /*
        "I am <a href='http://twitter.com/jonathansampson'>@jonathansampson</a>, and 
         I work with <a href='http://twitter.com/appendTo'>@appendTo</a>."
    */
    

    You might note that I used $& in JavaScript to grab the entire matched pattern while using $0 in PHP – we have to deal with these differences in life. My apologies 😉

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

Sidebar

Related Questions

My code take a lot time to load images from gallery. I store url
I'd like to mimic how this paging works: Notice how the current page will
I am having a lot of troubles with my C++ code but I can't
I'm building a website, and I can notice that the more code I add
There's a lot of non-detailed questions on this one, so here goes. What is
In some Delphi 7 code I am maintaining, I've noticed a lot of instances
I notice a lot of the examples for ASP.NET use Linq2Sql as the datasource.
I have a lot of legacy code which I currently compile using an antiquated
Say I have a string that looks like this: str = The &yquick &cbrown
I find that I make a lot of small changes to my source code,

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.