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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:25:55+00:00 2026-06-11T15:25:55+00:00

I am trying to extract a part of a string using regex. I have

  • 0

I am trying to extract a part of a string using regex. I have the following cases for string:

case1: Warehouse.13.season01episode01.hdtv.xor.avi
case2: Warehouse.13.s01e01.hdtv.xor.avi
case3: Warehouse.13.01x01.hdtv.xor.avi

The delimter(.) in the above string can be replaced by \s - _.

The logic am using is check if s or season is precided(lookbehind) by number and
extract everything before it but as look-behind need absolute length I reversed the string
and used look ahead on it.

Now for case1 I created the below regex which works fine and outputs Warehouse.13.

.*?\d{1,2}e\d{1,2}s\.(?=\d+)(.*)

Now for case2 I used:

.*?\d{1,2}edosipe\d{1,2}nosaes\.(?=\d+)(.*) # works fine.

Now when I try to combine the above two cases + optional delimiter like:

.*?\d{1,2}[e|edosipe]?[._ x\-]?\d{1,2}[s|nosaes]?[._\- ]?(?=\d+)(.*)

In the above case you can observe that most of the things are optinal(?). It is for the
case3.

Using the above regex doesn’t match anything for case2 but works fine for case1 and case3.

Any idea what is wrong here.

PS: I am aware there might be other possible string which will defy the above regex but
currently am not interested in them.

  • 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-11T15:25:56+00:00Added an answer on June 11, 2026 at 3:25 pm

    [e|edosipe] and [s|nosaes] should be (e|edosipe) and (s|nosaes), or (?:e|edopise) and (?:s|nosaes) if you don’t want the regex engine to capture them and mess up your accounting of $1, $2, etc.

    Here, (...) does parenthetical grouping much like it does in any other expression in Perl.
    [...] defines a character class. Specifically, [s|nosaes] matches a single character that is either a, e, n, o, s, and (perhaps surprisingly, but metacharacters special meanings are usually ignored inside [...]), |.

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

Sidebar

Related Questions

I am trying to extract some part of string and store it to hbase
I am using SQL Server 2008 & 2005 (Express). I'm trying to extract part
I'm trying to extract .zip files and I'm using this code: String zipFile =
Im trying to extract part of a line with perl use strict; use warnings;
im trying to extract some files from a jar-file downloaded using java-webstart. below code
I am trying to extract the video id from a youtube url using the
I have been using XPath with scrapy to extract text from html tags online,
I have been trying to put together something that allows me to extract points
I am trying to use the following script by duckrowing ( http://www.duckrowing.com/2010/03/18/documenting-objective-c-with-doxygen-part-ii/ ), to
I'm trying to make a regex which gets the part between two other things

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.