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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:47:20+00:00 2026-05-10T20:47:20+00:00

I am battling regular expressions now as I type. I would like to determine

  • 0

I am battling regular expressions now as I type.

I would like to determine a pattern for the following example file: b410cv11_test.ext. I want to be able to do a search for files that match the pattern of the example file aforementioned. Where do I start (so lost and confused) and what is the best way of arriving at a solution that best matches the file pattern? Thanks in advance.

Further clarification of question:

I would like the pattern to be as follows: must start with ‘b’, followed by three digits, followed by ‘cv’, followed by two digits, then an underscore, followed by ‘release’, followed by .’ext’

  • 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. 2026-05-10T20:47:20+00:00Added an answer on May 10, 2026 at 8:47 pm

    Now that you have a human readable description of your file name, it’s quite straight forward to translate it into a regular expression (at least in this case 😉

    must start with

    The caret (^) anchors a regular expression to the beginning of what you want to match, so your re has to start with this symbol.

    ‘b’,

    Any non-special character in your re will match literally, so you just use ‘b’ for this part: ^b.

    followed by […] digits,

    This depends a bit on which flavor of re you use:

    The most general way of expressing this is to use brackets ([]). Those mean ‘match any one of the characters listed within. [ASDF] for example would match either A or S or D or F, [0-9] would match anything between 0 and 9.

    Your re library probably has a shortcut for ‘any digit’. In sed and awk you could use [[:digit:]] [sic!], in python and many other languages you can use \d.

    So now your re reads ^b\d.

    followed by three […]

    The most simple way to express this would be to just repeat the atom three times like this: \d\d\d.

    Again your language might provide a shortcut: braces ({}). Sometimes you would have to escape them with a backslash (if you are using sed or awk, read about ‘extended regular expressions’). They also give you a way to say ‘at least x, but no more than y occurances of the previous atom’: {x,y}.

    Now you have: ^b\d{3}

    followed by ‘cv’,

    Literal matching again, now we have ^b\d{3}cv

    followed by two digits,

    We already covered this: ^b\d{3}cv\d{2}.

    then an underscore, followed by ‘release’, followed by .’ext’

    Again, this should all match literally, but the dot (.) is a special character. This means you have to escape it with a backslash: ^\d{3}cv\d{2}_release\.ext

    Leaving out the backslash would mean that a filename like ‘b410cv11_test_ext’ would also match, which may or may not be a problem for you.

    Finally, if you want to guarantee that there is nothing else following ‘.ext’, anchor the re to the end of the thing to match, use the dollar sign ($).

    Thus the complete regular expression for your specific problem would be:

    ^b\d{3}cv\d{2}_release\.ext$ 

    Easy.

    Whatever language or library you use, there has to be a reference somewhere in the documentation that will show you what the exact syntax in your case should be. Once you have learned to break down the problem into a suitable description, understanding the more advanced constructs will come to you step by step.

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

Sidebar

Related Questions

I am battling with this piece of code for days now, I really would
I have been battling with this piece of code for literally days now... Would
For some days now I've been battling with printing XPS to file without the
I've been battling with this for a few days now with no luck. I've
I've been battling with CSS z-index in IE7 foe a couple of hours now,
I've been battling with this issue for a couple of days now. I have
I've been battling with OAuth and Twitter for 2 weeks now trying to implement
Hey, I've been battling with PHP all morning and it's now really starting to
So I have been battling this issue for awhile now and tried many different
I have been battling like crazy with a javascript that allows for infinite scrolling

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.