0

I have the follow code:

string DB1 = DB1 = Regex.Match(contents, @"DB1=(?<DB1>[^\r\n]+)").Groups["DB1"].Value;

The code reads a file and looks for the following line:

DB1=Database\ABSER\ABSER

how can i modify the code that i have to exclude the 2nd \ABSER

I want my code to read only Database\ABSER , so essentially cut off the 2nd ABSER. I also need to kill this like at the \r\n. Thanks for all the help.

1
  • 4
    what's the idea of "(very quick answer)"? Commented Dec 22, 2009 at 19:40

2 Answers 2

1
string DB1 = DB1 = Regex.Match(contents, @"DB1=(?<DB1>.*)\\.*").Groups["DB1"].Value;

try that out.

Sign up to request clarification or add additional context in comments.

Comments

0
DB1=(?<dbname>.*(?=\\))

This just uses a positive look ahead, its extremely brittle, and only addresses the 2nd sub-directory. A trailing slash on the second ABSER and an additional directory will break it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.