P
poncenby
i have a file which has lines of text with fields separated by a space.
some of the fields are prefixed with a number and a space, like the
line below...
bar1 bar2 XX 10 bar3tooten
foo1 foo2 XX 15 foo3uptofifteen
as you can see, the numbers (10 and 15) are the length of the field
after the number.
so i want to use these numbers as length specifier to match the field
after the number, with a regex like either of these:
/(.+)\s(.+)\sXX\s([0-9)+)\s(.{$3})/
/(.+)\s(.+)\sXX\s([0-9)+)\s(.{\3})/
both regexs will make the program fall over when attempting to print
$4.
i've figured out a solution with a regex over two lines but am curious
why this doesn't work.
thanks in advance
poncenby
some of the fields are prefixed with a number and a space, like the
line below...
bar1 bar2 XX 10 bar3tooten
foo1 foo2 XX 15 foo3uptofifteen
as you can see, the numbers (10 and 15) are the length of the field
after the number.
so i want to use these numbers as length specifier to match the field
after the number, with a regex like either of these:
/(.+)\s(.+)\sXX\s([0-9)+)\s(.{$3})/
/(.+)\s(.+)\sXX\s([0-9)+)\s(.{\3})/
both regexs will make the program fall over when attempting to print
$4.
i've figured out a solution with a regex over two lines but am curious
why this doesn't work.
thanks in advance
poncenby