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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:09:11+00:00 2026-05-19T12:09:11+00:00

I am not good with preg_match or similar functions which are not deprecated. Here

  • 0

I am not good with preg_match or similar functions which are not deprecated.

Here are 2 strings:

  1. /Cluster-Computers-c-10.html

  2. /Mega-Clusters-c-15_32.html

I would to find out:

In number 1 example, how to get the value between -c- and .html (the value in the example is 10). The value is always an integer (numeric)

In number 2 example, how to get the value between -c- and .html (the value in the example is 15_32) . The value is always an integer seperated by _

Basically what I want to do is check if a string has either c-10.html or c-15_32.html and get the value and pass it to the database.

  • 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-19T12:09:11+00:00Added an answer on May 19, 2026 at 12:09 pm

    You can do:

    preg_match('/-c-(\d+(?:_\d+)?)\.html$/i',$str);
    

    Explanation:

    -c-     : A literal -c-
    (       : Beginning of capturing group
     \d+    : one or more digits, that is a number
     (?:    : Beginning of a non-capturing group
       _\d+ : _ followed by a number
     )      : End of non-capturing group
     ?      : Makes the last group optional
    )       : End of capturing group
    \.      : . is a metacharacter to match any char (expect newline) to match 
              a literal . you need to escape it.
    html    : a literal html
    $       : End anchor. Without it the above pattern will match any part 
              of the input string not just the end.
    

    See it

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

Sidebar

Related Questions

I am not good at doing preg_match() .Can someone help me create a preg_match()
Possible Duplicate: How to parse and process HTML with PHP? I'm not very good
Im not good at math, I could find everything so far, but not this
I'm not good at OOP design, but I need to demonstrate my knowledge to
I'm not good in English. What wrong with my text ^^ sorry :) I
Maybe the question sound not good or too simple. But not for me in
It seems not good for me, reporting errors like 'General Error: '+...., Is there
I am not good at SQL Server 2000. I have a comma-delimited list of
I am not good at jsp but I wondered what can cause such a
I'm not good at t-sql, so I need help. I have this code I

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.