Hi!
In the following example I would like to retrieve the text between pMAINp and the first pMDSp. The regex has a look-behind and a look-ahead:
string contents = "pMAINp MAP B FlightTest Load pMDSp ZutiCarrier pWingp some pMDSp more pWingp end";
string blockMainRegex = @"(?<=pMAINp)[\s\w+]+(?=(pMDS)?)";
The result I was hoping for was: " MAP B FlightTest Load "
but what it returns is: "MAP B FlightTest Load pMDSp ZutiCarrier pWingp some pMDSp more pWingp end"
You'll notice that I'm attempting a lazy match here: (pMDS)? which clearly isn't working! Any help with this would be much appreciated. Thanks. :-)
EDIT: Whoops, the sought text has been corrected.
This works great:
string blockMainRegex = @"(?<=pMAINp)[\s\w+]+?(?=pMDS)";