using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"Booking Voucher Number: (?<number>\d\d\d\d\d\d\d\d\d\d)|(Guest Name : (?<name>\w\w.*))|(Check In Date : (?<date>\d{4}-\d{2}-\d{2}))|(Check Out Date : (?<Outdate>\d{4}-\d{2}-\d{2}))|(Number of Rooms : (?<RoomNumbers>)\d.*)|(Special Request : (?<SRQST>\w.*))|(paid for Guests: (?<PfG>)\d.*)|(Room Type : (?<RoomType>)\w.*)";
string input = @"Booking Voucher Number: 2052892268
Guest Name : Maxie Dibbert
Check In Date : 2018-11-09
Check Out Date : 2018-11-10
Number of Rooms : 14
Booking Type : Pay At Hotel Amount To Be Collected : 91.2 (SOD)
Special Request : NA
Breakfast Included: No Breakfast
paid for Guests: 0
Room Type : Single Bed in Female Dormitory
";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
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