How do you extract sub strings from a string using regex? -
i have string
type: book year: 1991 title: "this book 1" isbn: 1234567890 pages: 500 authors: "smith, john";"brown, jack" mediatype: paperback
i wanted extract following sub-strings
book 1991 "this book 1" 1234567890 500 "smith, john" "brown, jack" paperback
so far, have extracted first 2 strings using following pattern
(\w+:)([\w\s]*\b)(\w+:)([\d\s]*\b)(\w+\b:)
i had many attempts extract string "this book 1" can't seem make out next group pattern this. tried 1 ("[^"]*")
returns no matches , can't seem rest of strings.
your inputs appreciated.
you try below regex.
@"(?<=: ).*?(?=\s+(?:\w+:)|$)"
in c#, may use
@"(?<=:\s+).*?(?=\s+(?:\w+:)|$)"
Comments
Post a Comment