Results 1 to 5 of 5

Thread: regex capital letter only of a string

  1. #1
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default regex capital letter only of a string

    i saw that from a previous post, this works to filter out only the numbers

    PHP Code:
    $string "this is a STring123 test";
    $numbers preg_replace('/.*?(\d+).*/''$1'$string);
    echo 
    $numbers
    but how can i modify that regex to filter out only the capital or lowercase ?
    Last edited by ggalan; 11-09-2010 at 06:00 PM.

  2. #2
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    actually i found that this will out put the last 3 digits of a string
    PHP Code:
    $str "My string";
    echo 
    substr($str, -3); 
    anyone know how to get the first 2 digits?

  3. #3
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    nm
    PHP Code:
    echo substr($str02); 

  4. #4
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    are you still needing help or did you find what you are looking for? from what I am reading I am not sure what exactly it is your script is being used for.
    To choose the lesser of two evils is still to choose evil. My personal site

  5. #5
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    originally i wanted a script / regex to pull only the upper or lower case of a string

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
  •