In the following example, I would like to get the text between pMAINp and first pMDSp. The regular expression has the appearance and forecast:
string contents = "pMAINp MAP B FlightTest Load pMDSp ZutiCarrier pWingp some pMDSp more pWingp end";
string blockMainRegex = @"(?<=pMAINp)[\s\w+]+(?=(pMDS)?)";
As a result, I was hoping: "Download MAP B FlightTest"
but it returns: "MAP B FlightTest Download pMDSp ZutiCarrier pWingp pFDSp more pWingp end"
You will notice that I am trying to find a lazy match here: (pMDS)? which is clearly not working! Any help with this would be greatly appreciated. Thank you. :-)
EDIT : Oops, the search text has been fixed.
This works fine:
string blockMainRegex = @ "(? <= PMAINp) [\ s \ w +] +? (? = PMDS)";
source
share