Results 1 to 6 of 6

Thread: Simple regex match **after** a period?

  1. #1
    Join Date
    Dec 2007
    Location
    Stranded in Sarasota Florida
    Posts
    75
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Question Simple regex match **after** a period?

    I'm trying to figure out how to make a regex to match after a period. In example the string 'af24cca.z' would match as 'z', or '24t24.4f' would match as '4f'.

    PHP Code:
    $cookie 'audio.0_backgroundimages._browserpatch.1';

    $my_pattern '/^(\.){1}/';

    list(
    $audio$backgroundimages$browserpatch) = split($my_pattern$cookie);
    echo 
    $audio
    In the script above the desired match in this instance would be '0'.

  2. #2
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    Code:
    $cookie = 'audio.0_backgroundimages._browserpatch.1'; 
    
    $my_pattern = '/^(\.){1}/'; 
    
    list($audio, $backgroundimages, $browserpatch) = split($my_pattern, $cookie); 
    echo $audio;
    ^ means at the beginning of the string meaning you want to split the string at the first character if it is a period.
    try
    Code:
    $my_pattern = '/(\.){1}/';
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@§†ê® §©®¡þ† /\/\@|{ê®
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  3. #3
    Join Date
    Dec 2007
    Location
    Stranded in Sarasota Florida
    Posts
    75
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Default

    Hmm, nothing is working; any suggestions for a more indepth regex cheat sheet?

  4. #4
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    after checking php.net, i think the regex should be [.]
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@§†ê® §©®¡þ† /\/\@|{ê®
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  5. The Following User Says Thank You to Master_script_maker For This Useful Post:

    JAB Creations (05-28-2008)

  6. #5
    Join Date
    Dec 2007
    Location
    Stranded in Sarasota Florida
    Posts
    75
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Default

    Ah! I see! I was using regex slashes / / though they are unnecessary and prevent the script from operating correctly. I figured it was regex, what's the catch?

  7. #6
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by Master_script_maker View Post
    after checking php.net, i think the regex should be [.]
    that would match any character, because the dot is a wildcard in terms of regular expressions, I am pretty sure you would need to do
    [\.]

    Quote Originally Posted by JAB Creations View Post
    Ah! I see! I was using regex slashes / / though they are unnecessary and prevent the script from operating correctly. I figured it was regex, what's the catch?
    can you re-phrase that?

    /expression/ is what lets the language know that what you are about to declare is a regular expression.

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
  •