1

I want to replace strings like

Dependencies\myfolder\1\2\abc.dll
Dependencies\myfolder\abc.dll
Dependencies\myfolder\1\abc.dll

with

packages\abc.dll.

What is the suitable regex pattern to do this. I was expecting the pattern to be -

Dependencies*abc.dll

So my code is -

 var newEntry = packages\abc.dll;
 var pattern = Dependencies*abc.dll;
 var allText = ""; //this contains the text read from a file
 Regex rgx = new Regex(pattern);
 rgx.Replace(allText, newEntry);

But this seems to be a wrong regex pattern.

1

1 Answer 1

3

Almost there you need the .* like:

Dependencies(.*)abc.dll

Online Demo

.NET Online Demo

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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.