Welcome to Welcome to DNF.com™ - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars

If you are new to domains and looking to buy, sell and learn about domains then you have come to the right place. DNForum is the largest domain name community on the internet and continues to grow every day. There are over 105,000 domainers on DNForum doing everything from buying domains, selling domains, learning about domains and discussing domains. Take a minute and Register.

Register Today on DNForum IT'S FREE!

Results 1 to 5 of 5
  1. #1
    DNF Addict
    Mr.Domains's Avatar
    Join Date
    Sep 2004
    Location
    Geneva, Switz.
    Posts
    1,868
    Country

    Great Britain
    DNF$
    3,239
    Bank
    6,090
    Total DNF$
    9,329
    Donate  

    Reg. Expression & Mod_Rewrite

    Hi,
    I am having a basic problem with Regular Expressions and the Mod_Rewrite rule. I need to pattern match the space (" ") character ???

    I am trying to rewrite a URL which contains a username variable:

    RewriteRule ^([a-zA-Z0-9_.]*)/index.html /index.php?username=$1 [L,NC]

    This works fine with usernames like "Dave_439" or "Emma.C", but unfortuantely the site I'm working on also alows users to have spaces in their username, so I also need to match "Dave 439" or "Emma C".

    Does anyone know how to include spaces in my Regular Expression?
    (Obviously I have tried [a-zA-Z0-9_. ]* which generates errors...)
    Neil Hillman - Web Developer, Pixel Pusher...

  2. #2
    David Ausman
    DavidAusman's Avatar
    Join Date
    May 2005
    Location
    127.0.0.1
    Posts
    853
    DNF$
    1,495
    Bank
    0
    Total DNF$
    1,495
    Donate  

    Re: Reg. Expression & Mod_Rewrite

    Probably you should use PHP to replace 'spaces' with something else that can be found within their username.

  3. #3
    DNF Addict
    Mr.Domains's Avatar
    Join Date
    Sep 2004
    Location
    Geneva, Switz.
    Posts
    1,868
    Country

    Great Britain
    DNF$
    3,239
    Bank
    6,090
    Total DNF$
    9,329
    Donate  

    Re: Reg. Expression & Mod_Rewrite

    Thanks, but I figured it out, you have to escape the space with a backslash:

    [a-zA-Z0-9_\.\ ]*
    Neil Hillman - Web Developer, Pixel Pusher...

  4. #4
    Formerly 'aZooZa'
    Dale Hubbard's Avatar
    Join Date
    Jan 2003
    Location
    UK Expat in CN
    Posts
    6,239
    Country

    England Follow Dale Hubbard On Twitter
    DNF$
    3,138
    Bank
    0
    Total DNF$
    3,138
    Donate  

    Re: Reg. Expression & Mod_Rewrite

    Try:

    \x20

    That represents dec 32 for 'space' in hex.

    OK - crossed posts - both should work
    Last edited by Dale Hubbard; 11-11-2005 at 04:47 AM. Reason: Automerged Doublepost

  5. #5
    David Ausman
    DavidAusman's Avatar
    Join Date
    May 2005
    Location
    127.0.0.1
    Posts
    853
    DNF$
    1,495
    Bank
    0
    Total DNF$
    1,495
    Donate  

    Re: Reg. Expression & Mod_Rewrite

    If you escape 'space' with backslash, what did the url looks like? I mean will it looks like this?
    1) http://yourdomain.com/dave%20439
    or this?
    2)http://yourdomain.com/dave_439

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Domain name forum recommended by Domaining.com