1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Regular Expressions

Discussion in 'Black Hat SEO Tools' started by meatro, Nov 9, 2011.

  1. meatro

    meatro BANNED BANNED

    Joined:
    Nov 21, 2009
    Messages:
    568
    Likes Received:
    997
    I'm trying to figure out the regular expression to delete the filename from a URL.

    I am not trying to get it down to the root domain, just remove the filename.

    I found this: \b\/.+

    but.. That doesn't work, I tried moving the ./ around, but that neither. It's for uBot, so I don't know if it's funky or what. I'm not too experienced with regex. :)

    Thanks.
     
  2. davids355

    davids355 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 25, 2011
    Messages:
    8,805
    Likes Received:
    6,372
    Home Page:
    I'm not expert but can you post examples of the initial URL then what you want it changed to.
     
  3. meatro

    meatro BANNED BANNED

    Joined:
    Nov 21, 2009
    Messages:
    568
    Likes Received:
    997
    No problem, I'm basically trying to keep everything except for the filename and/or parameters, if any.

    I figured it'd be easy, but I was dead wrong. The extension is always PHP, so what I thought was basically a regular expression for anything between "/" and ".php", keep the "/" but lose the ".php" and anything after it, if any. Returning only the URL up to the last category with a trailing slash.

    so...

    Code:
    http://www.website.com/index.php
    returns as
    Code:
    http://www.website.com/
    or
    Code:
    http://www.website.com/folder/default.php?a=1
    returns as
    Code:
    http://www.website.com/folder/
    Sorry, been working with uBot and I tried asking in their forums, but no replies. :\
     
    Last edited: Nov 10, 2011
  4. davids355

    davids355 Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 25, 2011
    Messages:
    8,805
    Likes Received:
    6,372
    Home Page:
    Something like this:
    (.*)/([/^]+.php)

    (any character any amount of times followed by a forward slash followed by any character at least one or more times except a forward slash, followed by .php (assuming that is always the extension).??
     
  5. luminus

    luminus Junior Member

    Joined:
    Oct 21, 2008
    Messages:
    112
    Likes Received:
    32
    Occupation:
    Operations, UBot Studio
    Location:
    Virtually Anywhere
    Home Page:
    Hey meatro, did someone help you out on the forum at UBot ? I looked just now and found a regex post that had a lot of responses so it looks like that was you but just making sure.
     
  6. lancis

    lancis Elite Member

    Joined:
    Jul 31, 2010
    Messages:
    1,632
    Likes Received:
    2,384
    Occupation:
    Entrepreneur
    Location:
    Milky Way
    Home Page:
    Use this to find the part of the string to be removed:

    Code:
    [^/]+$
    This basically tells to find every character that is not / till the end of the line.

    If you want to master regular expressions my advice is to get EditPlus 3, it gives you the option to search for regular expressions in an easy way (and replace them).
     
  7. fad3r

    fad3r Power Member

    Joined:
    Sep 17, 2011
    Messages:
    733
    Likes Received:
    115
    Location:
    nyc
    http://www.ultrapico.com/Expresso.htm that should help and it is free