Tuesday, 15 July 2014

regex - Deleting everything before and after matches -



regex - Deleting everything before and after matches -

i've searched , searched nil works need to.

my script doing correctly far; inputs text file, 1 long line of characters. script asks user first input sec input. i'm trying script remove characters come before first input , after sec input. don't want delete matching input itself.

e.g. if file contained "1111111111111111111111111cat1111dog11111111111", , user typed "cat" first input , "dog" sec input, want finish "cat1111dog".

i don't need help inputs , exports etc. it's working $line string. how can delete before first input variable , after sec input variable, without removing matches themselves? regex solution perhaps? input variables found in file might not same length way.

this give expect.

use warnings; utilize strict; @data = <data>; print "enter ther first value: "; chomp (my $first =<>) ; print "enter sec value: "; chomp (my $sec = <>); @ar =map{m/$first.*$sec/gi} @data; #simply print "@ar\n"; __data__ 1111111111111111111111111cat1111dog11111111111

i used map function match info begining , last. . matches expect newline * matches 0 or more occurrence.

regex perl

No comments:

Post a Comment