Yet another regex question.

S

siliconmike

Can anyone help me build a regex for these 2 problems:

Find 'x' if url starts with x and ends with .htm
eg.. xajgkdls3j5j223dmk.htm should match 'x'

Find '.htm' if url starts with x and ends with .htm
eg.. x45362adgAgdd346.htm should match '.htm'

Thanks
Mike
 
G

Gunnar Hjalmarsson

siliconmike said:
Can anyone help me build a regex for these 2 problems:

Find 'x' if url starts with x and ends with .htm
eg.. xajgkdls3j5j223dmk.htm should match 'x'

What on earth do you mean by "Find 'x'"?
Find '.htm' if url starts with x and ends with .htm
eg.. x45362adgAgdd346.htm should match '.htm'

Ditto: What do you mean by "Find '.htm'"?

Also: How do you recognize a URL?
 
S

siliconmike

What on earth do you mean by "Find"

find = match

I'm trying to use mod_rewrite of Apache to disguise dynamic pages as
static ones.

so if I match ".htm" successfully in "x45362.htm" (beginning with an x)
then I can replace .htm with .php

Mike
 
G

Gunnar Hjalmarsson

siliconmike said:
I'm trying to use mod_rewrite of Apache to disguise dynamic pages as
static ones.

so if I match ".htm" successfully in "x45362.htm" (beginning with an x)
then I can replace .htm with .php

This is how it can be done in Perl:

s/^(x.+\.)htm$/$1php/;

If you need help to do it using Apache's rewriting engine,
alt.apache.configuration might be a suitable newsgroup.
 
S

siliconmike

alt.apache.configuration migh....

Thanks for pointing that out. I'd got lost.
My problem is solved.. Thanks
Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top