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+:)|$)" 

demo


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -