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

  • Home
  • SEARCH
  • 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 7443875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:24:07+00:00 2026-05-29T11:24:07+00:00

I have a regexp pattern: <^(([a-z]+)\:([0-9]+)\/?.*)$> How do I avoid capturing the primary group?

  • 0

I have a regexp pattern:

<^(([a-z]+)\:([0-9]+)\/?.*)$>

How do I avoid capturing the primary group?

<^(?:([a-z]+)\:([0-9]+)\/?.*)$>

The above pattern will still put the whole string ‘localhost:8080’ into the first (0) group. But I need to get only 2 matched groups, so that first (0) group is populated with ‘localhost’ and second (1) with ‘8080’.

Where did I make a mistake?

  • 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-29T11:24:08+00:00Added an answer on May 29, 2026 at 11:24 am

    from the docs:

    matches

    If matches is provided, then it is filled with the results of search. $matches[0] will contain the text that matched the full pattern, $matches[1] will have the text that matched the first captured parenthesized subpattern, and so on.

    if you don’t care about the full match, you can use array_shift() to remove the unwanted element.

    array_shift($matches);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help about RegExp in AS3. I have a simple pattern :
I have this regexp Pattern pattern = Pattern.compile(\\{([^\\}]+)\\}); to match {a1|a2|a3} and {a4} format
I have html code as a string variable like a = <span> Spain will
My application will basically accept user input via the main(String[] args) method. I have
I'm currently building a tool that will have to match filenames against a pattern.
does php have a function that will convert a string (data type will be
I have an input string with a very simple pattern - capital letter, integer,
I have regexp to change smileys to images. Here it is (?:(?![0]:\)|:\)\)|:-\)\)))(:\)|:-\)) The point
I have a regexp I'm using with sed, but now I need to make
let's say I have two regexp's, /eat (apple|pear)/ /I like/ and text I like

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.