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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:58:47+00:00 2026-05-31T03:58:47+00:00

I have the following string: $/Mycollection/Branches/Dev/New/php/MySite/src/MySite/somefolder/src/sad.php I need to create regex pattern and take

  • 0

I have the following string:

$/Mycollection/Branches/Dev/New/php/MySite/src/MySite/somefolder/src/sad.php

I need to create regex pattern and take everything before first appearance of “src”.

I’ve tried to use like that .+(src) but as I understood I need to decrease greed, could anyone help ?

  • 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-31T03:58:48+00:00Added an answer on May 31, 2026 at 3:58 am

    You’re close. You can just do this…

    (^.+?)src
    

    Then get the value of the first group captured.


    You can also do this another way…

    src.+
    

    Then replace the match with "".

    For example (in C#) …

    string value = Regex.Replace(yourstring, "src.+", "");
    

    It’s actually much more efficient to use this method. It’ll do around 1 million iterations per second vs 150,000 iterations per second for the first method (at least in .NET). That’s partly because there’s some overhead in using capturing groups, and partly because of the backtracking that occurs with the lazy ? quantifier.

    By the way, I did the testing and benchmarking with Regex Hero and then here’s a good article that covers the lazy ? quantifier.

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

Sidebar

Related Questions

I have following string. $option = '+'; $value = '100'; I want create new
I have the following string in the smarty (php templating system) variable $test: <img
Have the following string i need to split. $string = This is string sample
I have following string adId:4028cb901dd9720a011e1160afbc01a3;siteId:8a8ee4f720e6beb70120e6d8e08b0002;userId:5082a05c-015e-4266-9874-5dc6262da3e0 I need only the value of adId,siteId and userId.
I have the following string: s=80 . I need to put this in an
Have following String built SQL query: StringBuilder querySelect = new StringBuilder(select * from messages
I have following string: text = '20 as a % of 50' I need
I have following string: {_id:scheme_version,_rev:4-cad1842a7646b4497066e09c3788e724,scheme_version:1234} and I need to get value of scheme version,
I have the following string: ID: 26bc76f7dbe507f9b5fb232748e52b51 To: 17135917389\n I need to pull out
I have the following string i need to parse to a date: 2012-01-31T08:41:12.5462495+01:00 now

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.