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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:48:15+00:00 2026-06-06T16:48:15+00:00

local invoiceData = [[I N V O I C E Invoice No. : ABCDEFG125469857

  • 0
local invoiceData =
[[I N V O I C E
Invoice No. :
ABCDEFG125469857
Invoice Date May
2012
]]

The pattern I am using is

 print (string.match(invoiceData,'\nInvoice Date (.-)\n'))

I want to fetch the string invoice date as MAY12. or 0512.. please help

Thanks

  • 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-06T16:48:17+00:00Added an answer on June 6, 2026 at 4:48 pm

    Instead of matching with .-, be more specific and use %w+ (alpha-nums) and %d+ (digits) to match the month and year.

    The script:

    local invoiceData =
    [[I N V O I C E
    Invoice No. :
    ABCDEFG125469857
    Invoice Date May
    2012
    ]]
    
    month, year = string.match(invoiceData,'Invoice%s+Date%s+(%w+)%s+%d*(%d%d)')
    print(month, year)
    

    will print:

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

Sidebar

Related Questions

i have this code local strs = my dog print (string.gsub( strs , ,%20))
Using (local) in the connection string doesn't work on my cluster. I'm assuming it's
local szMsg = string.format( 歡迎來到非常劍俠有獎問答,您隻需交納%s就可以參加本次有獎答題,隻要您能回答正確<color=yellow>%s個<color>關於劍俠世界的小問題,就會獲得%s,如果中途答錯或者自己選擇退出,不僅沒有獎勵,您交納的%s也不會退還。怎麼樣,要參加嗎?, szNeedMoney, self.tbGroup[nGroupId].nQuestionMax, szAwardMsg, szNeedMoney); local tbOpt = I want
Using local variables seems advisable in a partial that could be used application-wide to
I am running a local postgresql server in version 9.1 and using the postgresql-9.1-901.jdbc4.jar
How should my local Git workflow look? I'm using it to develop some software
My local airport disgracefully blocks users without IE, and looks awful. I want to
I have successfully scheduled local notifications in my app using the code below: Class
My local SVN tree of working copies is set up to match the directory
My local timezone is (UTC+10:00) Canberra, Melbourne, Sydney Sat 31-Mar-2012 15:59 UTC = Sun

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.