package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)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.*)`)
var str = `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
`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
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 Golang, please visit: https://golang.org/pkg/regexp/