Regular Expressions... - ...and a long list of questions

They have: 850 posts

Joined: Jul 1999

For question 1, *note this is an educated guess* it may look somthign like this (Correct me if i'm wrong!)

while($file =~ m/<a href=\"([0-9])([a-zA-Z0-9).html\">(.+?)</a>
{
$file = <a href="(.+?)([a-zA-Z)\">;
$file= $2;
}

I do not know the second question's answer off hand, but I can probably find it out.

Here is another educated guess for the third question:

$search="http://";
$site="http://www.go2net.com";

$site =~ s/$search//g;

Correct me If I am wrong, but that should look for $search inside the $site, and replace it with nothing?

They have: 69 posts

Joined: Apr 1999

*wow, this text box is huge ;)*

1) If the "thisIsAFile" is not variable (it's the same for all the files, here's the code:

if ($filename =~ /^(.+?)thisIsAFile.html/) { $integer = $1 }

2) Code:

$directory = "/home/usr/yourname";
opendir(D, $directory);
@files = readdir(D);
closedir D;

3) Code:

$string1 = "http://";
$string2 = "http://www.go2net.com";
foreach $letter (split(//, $string1)) {
$string2 =~ s/$letter//g;
}

Note that this last code will delete all H's from $string2, all T's, all P's and so on.

Cheers!

----------
Reviews of the best resources for webmasters in your e-mail every week!
Subscribe for [red]FREE[/red] by going to http://www.web-reviews.com/

They have: 297 posts

Joined: Apr 1999

Hi,

if you have a file name like this:

0123thisIsAFile.html

What would be the correct regular expression to extract the integer from that file name?

And if you have the answer handy, how do you get an array of the file names in a directory?

How can you "substract" a string from another string? Speak, you have two strings like "http://www.go.com" and "http," and you need the characters that only exist is one of them.

Thank You So Much, I love you all,

Malte

----------
Malte Ubl - [red]Germany[/red] - http://goKewl.com/
[red]The beats of 1000 hearts inside...[/red] the merciless pulsation... [red]and all I know is I'll be back...[/red] back to trance nation!

They have: 15 posts

Joined: Jun 2000

I think there is a problem with the forums. It did put my message to the top..

------------------

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.