using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?ms)<PNR>([\w]+)<\/PNR>
";
string input = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>
<EGE_Booking>
<TripID>1004-3637-360</TripID>
<RecordLocator>1004-3637-360</RecordLocator>
<Travelers>
<Traveler>
<PerCode>13593199</PerCode>
<FirstName>Claude</FirstName>
<LastName>Christensson</LastName>
<ContactDetails>
<Email>claude.christensson@wirelesscar.com</Email>
<MobilePhone>46765537005</MobilePhone>
</ContactDetails>
<TravellerCostCenter>
<CostCenter Code=""CC3"">
<Label>Employee ID</Label>
<Value>56524</Value>
</CostCenter>
<CostCenter Code=""CC4"">
<Label>Global Department code</Label>
<Value>DI43400</Value>
</CostCenter>
</TravellerCostCenter>
</Traveler>
</Travelers>
<Segments>
<HotelSegment>
<HOTEL>
<TripItemID>5a7dc8f971ac0163f7563e7e</TripItemID>
<PNR>ABC1DS</PNR>
<Status>V</Status>
<CheckInDate>2018-02-13</CheckInDate>
<CheckOutDate>2018-02-14</CheckOutDate>
<Vendor SupplierType=""11281422"">Genting Hotel</Vendor>
<PropertyName>Genting Hotel</PropertyName>
<Location>
<Name>Pendigo Way, England, B40 1PU</Name>
<City>Birmingham</City>
<Country Code=""GBR"">Storbritannien</Country>
</Location>
<ConfirmationCode>982674693</ConfirmationCode>
<Cost>
<Amount>751.08</Amount>
<Currency Code=""SEK"">Swedish Krona</Currency>
</Cost>
<OutOfPolicyReasons/>
</HOTEL>
<HOTEL>
<TripItemID>5a7dc8f971ac0163f7563e7e</TripItemID>
<PNR>55545261643</PNR>
<Status>V</Status>
<CheckInDate>2018-02-13</CheckInDate>
<CheckOutDate>2018-02-14</CheckOutDate>
<Vendor SupplierType=""11281422"">Genting Hotel</Vendor>
<PropertyName>Genting Hotel</PropertyName>
<Location>
<Name>Pendigo Way, England, B40 1PU</Name>
<City>Birmingham</City>
<Country Code=""GBR"">Storbritannien</Country>
</Location>
<ConfirmationCode>982674693</ConfirmationCode>
<Cost>
<Amount>751.08</Amount>
<Currency Code=""SEK"">Swedish Krona</Currency>
</Cost>
<OutOfPolicyReasons/>
</HOTEL>
</HotelSegment>
</Segments>
<Invoicing>
<CompanyCode>28781</CompanyCode>
<ClientNumber>28781</ClientNumber>
<ClientRequisition>claude.christensson@wirelesscar.com</ClientRequisition>
<ClientReference>689100277</ClientReference>
<ClientCostCenter>
<CostCenter Code=""CC1"">
<Label>Legal Entity</Label>
<Value>WirelessCar Sweden AB</Value>
</CostCenter>
<CostCenter Code=""CC2"">
<Label>Cost Center</Label>
<Value>989502</Value>
</CostCenter>
</ClientCostCenter>
</Invoicing>
</EGE_Booking>
";
foreach (Match m in Regex.Matches(input, pattern))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx