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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:37:38+00:00 2026-05-23T14:37:38+00:00

i have a string that looks like this: /dir/location/test-load-ABCD.p and i need to parse

  • 0

i have a string that looks like this:

"/dir/location/test-load-ABCD.p"

and i need to parse out “ABCD” (where ABCD will be a different value every day)

The only things that i know that will always be consistent (to use for the logic for parsing) are:

  1. There will always be be a “.p” after the value
  2. There will always be a “test-load-” before the value.

The things i thought of was somehow grab everything past the last “/” and then remove the last 2 characters (to take case of the “.p” and then to do a

 .Replace("test-load-", "")

but it felt kind of hacky so i wanted to see if people had any suggestions on a more elegant solution.

  • 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-23T14:37:38+00:00Added an answer on May 23, 2026 at 2:37 pm

    You can use a regex:

    static readonly Regex parser = new Regex(@"/test-load-(.+)\.p");
    
    string part = parser.Match(str).Groups[1].Value;
    

    For added resilience, replace .+ with a character class containing only the characters that can appear in that part.

    Bonus:
    You probably next want

    DateTime date = DateTime.ParseExact(part, "yyyy-MM-dd", CultureInfo.InvariantCulture);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string that looks like this... http://www.example.com/ example.pdf I need to remove
I have a string that looks like this: (12.0+10)*31 I need to be able
I have a string that looks like this: Name1=Value1;Name2=Value2;Name3=Value3 Is there a built-in class/function
i have a sub that looks like this: Sub open_esy(filename, p As String, p1
I have a String that looks like this String read = 1130:5813|1293:5803|1300:5755|1187:5731| As you
I have a string that looks like this: blah blah blah Team ID:</div>xxxxxxx blah
If I have a string that looks like this: This is a string with
I have an XML string that looks like this: <Attributes> <ProductAttribute id=1> <ProductAttributeValue> <Value>a</Value>
Say, we have a query string that looks like this: param1:'test1' && param2:'test2' I
I have an action method that looks like this: public ActionResult DoSomething(string par, IEnumerable<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.