P.O. Box Validation -- Hans?...Steve(Guru)?

Discussion in 'ASP .Net' started by Simple Simon, Nov 9, 2003.

  1. Simple Simon

    Simple Simon Guest

    Hi,
    I need some help getting this P.O. Box regular expression to work, or
    a new expression entirely. I got this one from a Google Groups
    search. It seems to work at: http://regexlib.com/ but not at runtime.

    I need to check if a P.O. Box exists in an address text box...UPS
    won't ship some items to a P.O. Box.

    ValidationExpression="(?i)^((?<!P\.?\s?O\.?\sBox).)+(?<!P\.?\s?O\.?\sBox)$"

    Please help?

    TIA,
    ~Gordon
    Simple Simon, Nov 9, 2003
    #1
    1. Advertising

  2. Simple Simon

    Brian W Guest

    Actually, I think you will find that UPS won't ship _ANYTHING_ to a P.O. Box

    Keep in mind also, as you suggest this is valid:

    P O Box 123

    but so are these:

    P.O. Box 123
    PO Box 123
    P O Box 123
    Box 123
    #123

    (I'm sure I missed some combinations)

    You will have to check for each one as may vary from person to person.

    In addition UPS may ship to:

    132 Main Street
    Box 123
    Anytown, USA

    as it may be a Mailbox Etc. (now UPS Store) store

    Just some extra food for thought


    Good luck
    Brian W

    "Simple Simon" <> wrote in message
    news:...
    > Hi,
    > I need some help getting this P.O. Box regular expression to work, or
    > a new expression entirely. I got this one from a Google Groups
    > search. It seems to work at: http://regexlib.com/ but not at runtime.
    >
    > I need to check if a P.O. Box exists in an address text box...UPS
    > won't ship some items to a P.O. Box.
    >
    >

    ValidationExpression="(?i)^((?<!P\.?\s?O\.?\sBox).)+(?<!P\.?\s?O\.?\sBox)$"
    >
    > Please help?
    >
    > TIA,
    > ~Gordon
    Brian W, Nov 9, 2003
    #2
    1. Advertising

  3. Simple Simon

    Simple Simon Guest

    Thanks for the cautions Brian, you got a regular expression for that?
    :p

    ~Gordon

    On Sun, 9 Nov 2003 14:56:48 -0800, "Brian W"
    <brianw@gold_death_2_spam_rush.com> wrote:

    >Actually, I think you will find that UPS won't ship _ANYTHING_ to a P.O. Box
    >
    >Keep in mind also, as you suggest this is valid:
    >
    > P O Box 123
    >
    >but so are these:
    >
    > P.O. Box 123
    > PO Box 123
    > P O Box 123
    > Box 123
    > #123
    >
    >(I'm sure I missed some combinations)
    >
    >You will have to check for each one as may vary from person to person.
    >
    >In addition UPS may ship to:
    >
    > 132 Main Street
    > Box 123
    > Anytown, USA
    >
    >as it may be a Mailbox Etc. (now UPS Store) store
    >
    >Just some extra food for thought
    >
    >
    >Good luck
    >Brian W
    >
    >"Simple Simon" <> wrote in message
    >news:...
    >> Hi,
    >> I need some help getting this P.O. Box regular expression to work, or
    >> a new expression entirely. I got this one from a Google Groups
    >> search. It seems to work at: http://regexlib.com/ but not at runtime.
    >>
    >> I need to check if a P.O. Box exists in an address text box...UPS
    >> won't ship some items to a P.O. Box.
    >>
    >>

    >ValidationExpression="(?i)^((?<!P\.?\s?O\.?\sBox).)+(?<!P\.?\s?O\.?\sBox)$"
    >>
    >> Please help?
    >>
    >> TIA,
    >> ~Gordon

    >
    Simple Simon, Nov 10, 2003
    #3
  4. Simple Simon

    Vishnu Sistla

    Joined:
    Oct 9, 2011
    Messages:
    1
    This Java method should work.
    /**
    * The below are the possible combinations P.O.BOX, PO.BOX, P O BOX, P O B O
    * X, POBOX, PO BOX, P.O.B.O.X
    *
    * @param input
    * @return true if the input value = pobox else false
    */
    public static boolean checkPoBox(String input) {
    boolean poBox = false;
    String inputVal = input;
    try {
    if (input.length() > 4) {
    inputVal = inputVal.replace(".", "").replace(" ", "")
    .toLowerCase();
    if (inputVal.contains("pobox")
    || inputVal.equalsIgnoreCase("pobox")) {
    poBox = true;
    }
    }
    } catch (Exception e) {
    log.debug("Exception from checkPoBox");
    }
    return poBox;
    }
    Vishnu Sistla, Oct 9, 2011
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ¿À¼º¿µ

    thanks you , Steve...

    ¿À¼º¿µ, Feb 9, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    381
    ¿À¼º¿µ
    Feb 9, 2006
  2. Richard

    Steve Pugh

    Richard, Nov 12, 2003, in forum: HTML
    Replies:
    9
    Views:
    622
    informant
    Nov 14, 2003
  3. Dave Benjamin

    Guido interviewed by Steve Holden

    Dave Benjamin, Aug 17, 2003, in forum: Python
    Replies:
    0
    Views:
    567
    Dave Benjamin
    Aug 17, 2003
  4. Dave Harrison

    Re: Guido interviewed by Steve Holden

    Dave Harrison, Aug 17, 2003, in forum: Python
    Replies:
    0
    Views:
    574
    Dave Harrison
    Aug 17, 2003
  5. Erik Wikström
    Replies:
    1
    Views:
    369
    gpderetta
    Apr 16, 2008
Loading...

Share This Page