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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:21:13+00:00 2026-06-17T19:21:13+00:00

Say you have a pattern like this: @[a-z]+\s[\d] is it useful to have something

  • 0

Say you have a pattern like this:

@[a-z]+\s[\d] 

is it useful to have something like this:

(@[a-z]+\s[\d])

in any situation? Is there any difference between them? How so?

  • 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-17T19:21:14+00:00Added an answer on June 17, 2026 at 7:21 pm

    The () are used for capturing data. If you try to match "My name is John" without capturing:

    /My name is [A-Z][a-z]+/
    

    Then the result would simply be the string:

    ("My name is John")
    

    If you want to capture the name separately from the result then you can use the () like this:

    /My name is ([A-Z][a-z]+)/
    

    This will return the entire match (it is a convention to always return the entire match as the first result item), and it will also return the captured name, like so:

    ("My name is John", "John")
    

    If we want to capture the first and last name in "My name is John Doe" then we can do it like this:

    /My name is ([A-Z][a-z]+) ([A-Z][a-z]+)/
    

    The result:

    ("My name is John Doe", "John", "Doe")
    

    So, to answer your question, there is really no difference between the two expressions. The first will just match a string, while the second will match and capture it (in this case you would basicaly just end up with two identical results).

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

Sidebar

Related Questions

Lets say i have a piece of code like this: test pattern | pattern
Say I have something silly like this: data SomeType = Unary Int | Associative
Say I have some data like this: number_stream = [0,0,0,7,8,0,0,2,5,6,10,11,10,13,5,0,1,0,...] I want to process
Let's say I have an annotation JSR 303 class like this: class A {
Let's say I have this code: val string = one493two483three val pattern = two(\d+)three.r
Let's say I have a list looking like this: List=[alpha(1,2),beta(3,4),gamma(4,1)] Ok, so I want
Lets say I have a javascript library (.js file) which does something like drawing
Lets say I have an interface like this: public interface MyInterface { int Property1
Say I have a byte like this 1010XXXX where the X values could be
Say I have the text abcabx. I would like to know that there is

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.