I need help with a reg ex...

Discussion in 'Programming' started by ImpulseHorizon, Apr 26, 2009.

  1. #1
    "involving the medial temporal lobes
    (see Figure 32.5). The brain FDG-PET frequently shows
    uptake of FDG in the medial temporal lobes, even when the
    MRI is normal (Fakhoury et al., 1999). Almost all patients
    have an abnormal EEG that includes uni- or bilateral temporal
    lobe epileptic discharges, or slow background activity.
    The combination of clinical, MRI, EEG, and CSF
    findings, along with antineuronal antibody testing, identify
    most cases of paraneoplastic LE (Lawn et al., 2003). Recent
    studies have shown three groups of immune-mediated"

    in the sample text, I need to match things in parentheses so \(.*?\)
    but I only want things in parentheses that have an ending parentheses with four numbers at the end

    \(.*?\) matches:
    (see Figure 32.5)
    (Fakhoury et al., 1999)
    (Lawn et al., 2003)

    but I need something that only matches:
    (Fakhoury et al., 1999)
    (Lawn et al., 2003)

    I tried \(.*?\d\d\d\d\) but it is matching:
    (see Figure 32.5). The brain FDG-PET frequently shows uptake of FDG in the medial temporal lobes, even when the MRI is normal (Fakhoury et al., 1999)
    (Lawn et al., 2003)


    I need to somehow check for another opening parentheses in the .*? and not match if it finds one but I don't know how to do that within the reg ex

    thank you
     
    ImpulseHorizon, Apr 26, 2009 IP
  2. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #2
    You should not use .* try something like a-z|A-Z|\- ,etc .
     
    it career, Apr 27, 2009 IP
  3. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #3
    Hi,

    
    $s='involving the medial temporal lobes
    (see Figure 32.5). The brain FDG-PET frequently shows
    uptake of FDG in the medial temporal lobes, even when the
    MRI is normal (Fakhoury et al., 1999). Almost all patients
    have an abnormal EEG that includes uni- or bilateral temporal
    lobe epileptic discharges, or slow background activity.
    The combination of clinical, MRI, EEG, and CSF
    findings, along with antineuronal antibody testing, identify
    most cases of paraneoplastic LE (Lawn et al., 2003). Recent
    studies have shown three groups of immune-mediated';
    $arr=array();
    preg_match_all('#\([^\)]*\d{4}\)#',$s,&$arr);
    if (count($arr[0])) echo implode('<br />',$arr[0]);
    
    PHP:
    Cheers :)
     
    koko5, Apr 27, 2009 IP