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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:38:40+00:00 2026-06-08T16:38:40+00:00

base string is: IP: 192.168.0.1 Passing that string to string.gmatch function(besides below patterns) will

  • 0

base string is: IP: 192.168.0.1

Passing that string to string.gmatch function(besides below patterns) will return the following results:

pattern: IP: (%d+.%d+.%d+.%d+)
–>192.168.0.1

pattern: IP: %d+.%d+.%d+.%d+
–>IP: 192.168.0.1

My question is that what are the meaning of those parentheses to the Lua pattern matching engine?
Why by using the parentheses in the first pattern, the IP: string omitted but in the second pattern no?

  • 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-08T16:38:43+00:00Added an answer on June 8, 2026 at 4:38 pm

    Anything inside parentheses is a capture group; any part of the input string matched by the part of the pattern in parentheses is captured and returned by match() and gmatch(). If there are no capture groups in the pattern, the entire string is returned.

    local x, y, z = ("123456"):match("(%d)%d(%d)%d(%d)%d")
    print(x, y, z)
    -- 1, 3, 5
    

    At any point after the associated capture group is specified, %1, %2 etc. may be used to access the captured value:

    local x, y = ("123123123"):match("(%d%d%d)%1(%1)")
    print(x, y)
    -- 123, 123
    

    This is most often seen in the third parameter of string.gsub(), but may be used in any of the pattern matching functions.

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

Sidebar

Related Questions

I have the following three classes public class Base { string name; } public
I have the following hierarchy: class Base { public Base(string sMessage) { //Do stuff
I have few types that derive from simplified Base as shown below. I am
Im writing a base 64 string that i have made from an image to
the password string is some kind of like that MTY5LTYtNjEtMjAxLTkwLTE3MS05My0yMDAtMTMxLTE5Mi01My0xNjItMC0yMjAtMTgxLTIyNg== I tried base 64
I am trying write a PHP function that returns a random string of a
I am creating HTML pages with a base string and annotations on top of
class FxRate { string Base { get; set; } string Target { get; set;
[Serializable] public class SampleBase { [HumanReadableAttribute(The Base)] public string BaseProp { get; set; }
I have a web service. I use it to accept a base 64 string

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.