diff options
Diffstat (limited to 'regexp.txt')
-rw-r--r-- | regexp.txt | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/regexp.txt b/regexp.txt new file mode 100644 index 0000000..7cef9cb --- /dev/null +++ b/regexp.txt @@ -0,0 +1,15 @@ +[regexp] +- difference between ([^c])+ and ([^c]+) heh :p? first matches last letter occurence, latter matches whole string + +- grep a cl page +# grep -E "^\\s*<a\\s+href\\s*=\\s*['\"]+([^'\"])+['\"]\\s*>\\s*([^<])+</a>\\s*$" cl.html + +- same but using sed, notes how forward-slash in '</a>' got escaped +$ sed -n -r "/^\\s*<a\\s+href\\s*=\\s*['\"]+([^'\"])+['\"]\\s*>\\s*([^<])+<\/a>\\s*$/p" cl.html + +- now sed with 2 column output, link mapping to desc, note that +'s were moved into () +$ sed -r -n "s/^\\s*<a\\s+href\\s*=\\s*['\"]+([^'\"]+)['\"]\\s*>\\s*([^<]+)<\/a>\\s*$/\1 \2/p" cl.html + +- full cl search +$ curl -s -i 'http://chicago.craigslist.org/search/pta?query=wrx+|+sti+|+impreza+|+subaru&srchType=T' | sed -r -n "s/^\\s*<a\\s+href\\s*=\\s*['\"]+([^'\"]+)['\"]\\s*>\\s*([^<]+)<\/a>\\s*$/\1 \2/p" + |