I need to write regular expression that will parse strings like this:
Build-Depends: cdbs, debhelper (>=5), smthelse
I want to extract package names (without version numbers and brackets).
I wrote something like this:
$line =~ /^Build-Depends:\s*(\S+)\s$/
But it’s not exactly what I want.
Does someone know how to manage it?
P.S. I just want to get the list: “cdbs debhelper smthelse” as a result
This regex should do what you want:
/\s(\S*)(?:\s\(.*?\))?(?:,|$)/gEdit: You’d call it like this to loop through all the results: