Saturday, 15 May 2010

linux - cut matched and put in another location -


How can I cut numbers that are in the square brackets and put them at the beginning of the text? For example:

  some_text123_ [12345] after _some_text: 12345_some_text123 _ [] _ ​​some_text    < P> 

I tried to use perl .

This Pearl should work a liner. $ echoing some Atekote 123_ [123] _some_text | Perl -ne 'print "$ 1_", "$` "," $' \ '\ \ "if / \ [(\ d +?) \] /; $ <->

$ `-

Just to explain the special variable from perl regex engine:

$ 1 - How do I protect it on mail Want to

$ `-

$ '- after everything after match

No comments:

Post a Comment