question

58901228 avatar image
0 Votes"
58901228 asked 58901228 commented

How do regular expressions match as few expressions as possible?


Similar to the following string, I need to match "cpoyme"

 <This a test>Copyme<End><End>


My pattern= @"(?<=<This a test>).+(?=<)" ,but match value is "Copyme<End>".

How do I write a pattern?

dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered 58901228 commented

Try adding a '?':

 pattern = @"(?<=<This a test>).+?(?=<)";
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

you are good!

0 Votes 0 ·