0

I have been trying to extract last six numbers of an URL in each line of the original text and add it to another code that must be added to the result text. There also need to remove some code of each line from the original text and replace it with new code in the result text.

input http://riyajr.googlepages.com/original.txt

output http://riyajr.googlepages.com/result.txt

Is there any software that can do the above task? Please help me with any other options available. It would be great if someone could provide me with the full script code that could do above task.

1

2 Answers 2

2

Yes, lots. It is a basic application for any scripting language - Perl or Python or ...

0

php:

$infile = "in.txt";
$outfile = "out.txt";

foreach (file($url) as $line)
{

    //extract last 6 chars
    $chars = substr($line, -6);

    // append the last 6 chars to a outfile
    file_put_contents($outfile, "$chars\n", FILE_APPEND);
}

Note this isn't doing any regular expressions to determine if the last 6 chars are number it just blindly grabs them.

Get a good scripting book!

Not the answer you're looking for? Browse other questions tagged or ask your own question.