package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^.*?p1_1_(?:(?!\|@\|).|\|{2})*\|([^|]+)(?:\|@\||$)`)
var str = `text|p1_1_1120170AS074192161A0Z20|C M E - Rectifier|@|text|p1_2_1120170AS074192161A0Z20|Huawei|@|text|p1_3_1120170AS074192161A0Z20|Rectifier Module 3KW|@|text|p1_4_1120170AS074192161A0Z20|Shuangdeng 6-FMX-170|@|text|p1_5_1120170AS074192161A0Z20|24021665|@|text|p1_6_1120170AS074192161A0Z20|1120170AS074192161A0Z20|@|text|p1_7_1120170AS074192161A0Z20|OK|@|text|p1_8_1120170AS074192161A0Z20||@|text|p1_9_1120170AS074192161A0Z20|ACTIVE|@|text|p1_10_1120170AS074192161A0Z20|-OK|@|text|site_id|20MJK110|@|text|barcode_flag|auto|@|text|movement_flag||@|text|unit_of_measurement||@|text|flag_waste|no|@|text|req_qty_db|2|@|text|req_qty|2
text|p1_1_1120170AS074192161A0Z20||@|text|p1_2_1120170AS074192161A0Z20|Huawei|@|text . . .`
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/