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

The Archive Base Latest Questions

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

I need to validate strings like this: $string = ‘test3-10-2’; I need the penultimate

  • 0

I need to validate strings like this:

$string = 'test3-10-2'; 

I need the penultimate number between hyphens, so in this case ’10’. These are other examples:

$string2 = 'test45-50-178-1';  //match = 178
$string3 = 'test45-580-89-12-1';  //match = 12

Can you help me?

  • 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-16T02:16:28+00:00Added an answer on June 16, 2026 at 2:16 am

    this RegExp should do the trick using a positive lookahead: (change 4 to whatever max num of digits you want to allow)

    \d{1,4}(?=-\d{1,4}$)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my application takes in a string like this 2002-10-15 10:55:01.000000. I need to validate
I need to validate a in a method like this. validateFileName(Editable s) { String
Really got stuck on this simple regex. Need it to validate a string, that
I have a tag like this <order>foo,bar,goo,doo,woo</order> that I need to validate with an
I need to validate input to my application. The input is a formatted string
I need a regex or a function in PHP that will validate a string
I need to validate file name with following pattern.... File name(string) should not be
I need to validate the membership card number of a table to be unique
I need to validate serial numbers. For this we use regular expressions in C#,
In my experience I call simple web methods, like this: [WebMethod] public List<string> GetUserListByLetters(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.