Quantcast
Channel: Capturing Groups From a Grep RegEx - Stack Overflow
Viewing all articles
Browse latest Browse all 11

Answer by towith for Capturing Groups From a Grep RegEx

$
0
0

I prefer the one line python or perl command, both often included in major linux disdribution

echo $'<a href="http://stackoverflow.com"></a><a href="http://google.com"></a>' |  python -c $'import reimport sysfor i in sys.stdin:  g=re.match(r\'.*href="(.*)"\',i);  if g is not None:    print g.group(1)'

and to handle files:

ls *.txt | python -c $'import sysimport refor i in sys.stdin:  i=i.strip()  f=open(i,"r")  for j in f:    g=re.match(r\'.*href="(.*)"\',j);    if g is not None:      print g.group(1)  f.close()'

Viewing all articles
Browse latest Browse all 11

Latest Images

Trending Articles





Latest Images