[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] Udfordring med awk og regulær udtryk



Den 15-01-2011 13:03, Jesper K. Pedersen skrev:
 ......

> awk '{ match($0, /(.*)\<([[:alnum:]_-]+)$/, arr); sub("[ \t]+$","",
> arr[1]); print "insert into imdb_genres values
> (\x27"arr[1]"\x27,\x27"arr[2]"\x27);"}'
> 
> 
> Mit awk program ser ud som ovenstående.
> 
> Desværre render jeg ind i at den deler genren i genren hvis der er "-"
> i genren - som "Sci-Fi".
> 
> 
> Jeg havde forventet at \<[[:alnum:]_-]+$ ville match al tekst fra en
> orddelin incl "-" indtil slutningen af linien. Men det virker ikke.

det er vist den \<  (empty string) match beginning af WORD der driller?

kan
 match($0, /(.*)[[:space:]]+([[:alnum:]_-]+)$/, arr)
ikke gøre det?
hvis du ved der er et eller flere blanktegn inden genre.


fandt dette om "Word":
"In all flavors, the characters [a-zA-Z0-9_] are word characters."
dvs. "-" er ikke et WORD og din match er netop :  Fi$



PS
ovenstående match vil fejle hvis der er andre tegn end de angivne alnum _ -
efter genre og inden linieskift.
.



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2011-02-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *