Yet another regex question.

Discussion in 'Perl Misc' started by siliconmike, Apr 18, 2005.

  1. siliconmike

    siliconmike Guest

    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
    siliconmike, Apr 18, 2005
    #1
    1. Advertising

  2. siliconmike wrote:
    > 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?

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Apr 18, 2005
    #2
    1. Advertising

  3. siliconmike

    siliconmike Guest

    > 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
    siliconmike, Apr 18, 2005
    #3
  4. siliconmike wrote:
    > 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.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Apr 18, 2005
    #4
  5. siliconmike

    siliconmike Guest

    > alt.apache.configuration migh....

    Thanks for pointing that out. I'd got lost.
    My problem is solved.. Thanks
    Mike
    siliconmike, Apr 18, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Martin
    Replies:
    3
    Views:
    388
    Martin
    Jul 24, 2003
  2. Replies:
    6
    Views:
    5,331
    Alan Moore
    May 24, 2005
  3. Berehem
    Replies:
    4
    Views:
    553
    Lawrence Kirby
    Apr 28, 2005
  4. Replies:
    3
    Views:
    757
    Reedick, Andrew
    Jul 1, 2008
  5. sjp
    Replies:
    13
    Views:
    173
    A. Sinan Unur
    Apr 9, 2005
Loading...

Share This Page