in reply to Re: Fine tuning a reg exp (\w)
in thread Fine tuning a reg exp

Thanks, still learning reg exps. Even if I do this:
^([A-Z]+\s[A-Z]+,)
I still get lowercase characters:
ABU BAKR Sabaqah School

Replies are listed 'Best First'.
Re^3: Fine tuning a reg exp (\w)
by toolic (Bishop) on Feb 23, 2012 at 15:40 UTC
    I don't get that output with your regex:
    use warnings; use strict; while (<DATA>) { print if /^([A-Z]+\s[A-Z]+,)/; } __DATA__ ABU BAKR, Ibrahim Ali Muhammad (a.k.a. AL-LIBI, Abd al-Muhsin) (individual) [SDGT] AFGHAN SUPPORT COMMITTEE (ASC) (a.k.a. AHYA UL TURAS; a.k.a. JAMIAT AYAT-UR-RHAS AL ISLAMIA; a.k.a. JAMIAT IHYA UL TURATH AL ISLAMIA; a.k.a. LAJNAT UL MASA EIDATUL AFGHANIA) Grand Trunk Road, near Pushtoon Garhi Pabbi, Peshawar, Pakistan; Cheprahar Hadda, Mia Omar Sabaqah School, Jalalabad, Afghanistan [SDGT]

    prints:

    ABU BAKR, Ibrahim Ali Muhammad (a.k.a. AL-LIBI, Abd al-Muhsin)

    See http://sscce.org

Re^3: Fine tuning a reg exp (\w)
by tye (Sage) on Feb 23, 2012 at 15:40 UTC

    Since the regex you show will not match any lowercase letters and requires a comma and the match you show contains lowercase letters and no comma, I'm pretty sure you are not running the code you think you are (or similar mistake).

    - tye        

Re^3: Fine tuning a reg exp (\w)
by choroba (Cardinal) on Feb 23, 2012 at 15:44 UTC
    Negative.
    perl -e 'print "Sabaqah School," =~ /^([A-Z]+\s[A-Z]+),/ ? "Yes" : "No +"' No
Re^3: Fine tuning a reg exp (\w)
by bitingduck (Deacon) on Feb 23, 2012 at 16:23 UTC

    Try posting your complete regex from "s" through ";" (e.g. s/([ A-Z]+)/myreplacement/gixm; -- it will make it clear what you're actually applying.

    Even better, post a small chunk of runnable code. It sounds from previous posts that you're just reading in lines and processing them in a pretty straightforward way, so the code should be quite short.

    A couple hours with a regex tutorial would also help you get going faster- the questions you're posting are chapter 1 or 2 kind of things, because they're almost the first thing everyone wants to do.

Re^3: Fine tuning a reg exp (\w)
by brx (Pilgrim) on Feb 23, 2012 at 16:20 UTC