regex - Extract Text From CSV -


i want grab regular expressions out of snort rules.

here's example of text i've saved csv - https://rules.emergingthreats.net/open/snort-2.9.0/rules/emerging-exploit.rules

so there multiple rules,

#by akash mahajan # alert udp $external_net -> $home_net 14000 (msg:"et exploit borland visibroker smart agent heap overflow"; content:"|44 53 52 65 71 75 65 73 74|"; pcre:"/[0-9a-za-z]{50}/r"; reference:bugtraq,28084; reference:url,aluigi.altervista.org/adv/visibroken-adv.txt; reference:url,doc.emergingthreats.net/bin/view/main/2007937; classtype:successful-dos; sid:2007937; rev:4;) 

and want text appears after "pcre" in of them, extracted , printed new file, without quotes

 pcre:"/[0-9a-za-z]{50}/r"; 

so, line above, want end below text;

 /[0-9a-za-z]{50}/r 

from every place "pcre" appears in whole file.

i've been messing around grep, awk, , sed. can't figure out. i'm new this.

could give me tips?

thanks

with gnu sed:

$ sed -n -r 's/.*\<pcre:"([^"]+).*/\1/p' file /[0-9a-za-z]{50}/r 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -