regex - Sed match ^ NOT operand with .* anyString Matches -


please, if incorporate answer working sed line.

solution:

sed -r "s/([^]].*)\[/\1\r[/g" testfile.txt 

solution handles both sides of bracket, , removes tabs

sed -r "s/\t//g;s/([^]].*)\[/\1\r[/g;s/\]([^[].*)$/]\r\1/g" testfile.txt 

i have gnuwin32 (working) sed line:

sed -r "s/(.*)\[/\1\r[/g" testfile.txt 

what is

s/ (.*)\[  - matches anystring[ / \1\r[   - splits anystring<insertscarriagereturn>[ /g 

what i'd use ^ (not operand) exclude anystring being "]"

so...

before pretty this

*[ 

becomes

* [ 

however...

if * == ], i'd not perform operation.

it suggested ^\[

however don't know where/how implement ^ operator on variable stringmask such (.*). .* being string matter when i'm trying text if * is/ends ]?

i'm thinking either

(.*^\[) 

or

(.*)^\[ 

any appreciated.

here's sample data set

item_gloves  [object:item]  ###test###     [item_gloves:item_gloves_gauntlets]###test### [name:gauntlet:gauntlets] ###test###[armorlevel:2] [upstep:1] ###test###[shaped] [layer:armor]###test######test### [coverage:100] [layer_size:20] [layer_permit:15] [material_size:2] [scaled] [barred] [metal] [leather] [hard] 

sed -r "s/^([^]]*)\[/\1\r[/g" testfile.txt 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -