Regular Expression help!

Discussion in 'Java' started by shilpa, Sep 15, 2005.

  1. shilpa

    shilpa Guest

    Hello,

    I am trying to parse string buffer by using Regular Expression.
    Suppose my string buffer is:

    -------------------------------------------
    Hi , How are you?

    Hello: abc

    hurrey : [ this is test msg
    Pls reply to this mail
    Hello: xyz
    Test1
    ]

    -------------------------------------------

    I want to search string: "Hello: anystring till end of line" which is
    not included in [].
    So In above example my Regular expression should only find

    first "Hello: abc".

    Is it possible by using Regular expression?
     
    shilpa, Sep 15, 2005
    #1
    1. Advertising

  2. shilpa

    Roedy Green Guest

    Roedy Green, Sep 15, 2005
    #2
    1. Advertising

  3. shilpa

    Roedy Green Guest

    On 14 Sep 2005 23:46:07 -0700, "shilpa" <> wrote
    or quoted :

    >Is it possible by using Regular expression?


    Yes. To find out how, see http://mindprod.com/jgloss/regex.html

    You need to learn regex as a whole.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
     
    Roedy Green, Sep 15, 2005
    #3
  4. shilpa

    Oliver Wong Guest

    "shilpa" <> wrote in message
    news:...
    > Hello,
    >
    > I am trying to parse string buffer by using Regular Expression.
    > Suppose my string buffer is:
    >
    > -------------------------------------------
    > Hi , How are you?
    >
    > Hello: abc
    >
    > hurrey : [ this is test msg
    > Pls reply to this mail
    > Hello: xyz
    > Test1
    > ]
    >
    > -------------------------------------------
    >
    > I want to search string: "Hello: anystring till end of line" which is
    > not included in [].
    > So In above example my Regular expression should only find
    >
    > first "Hello: abc".
    >
    > Is it possible by using Regular expression?


    I don't think this is possible, particularly if you allow nesting of
    brackets. Consider:

    [[[[]]]
    Hello: How are you?
    [[[]]]]

    This requires bracket-balancing, which requires at least the power of a
    context-free grammar, so no, regular expressions are not powerful enough to
    accept this language.

    - Oliver
     
    Oliver Wong, Sep 20, 2005
    #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. Anand

    Regular Expression help...

    Anand, Jul 9, 2003, in forum: Perl
    Replies:
    1
    Views:
    1,231
    Eric J. Roode
    Jul 9, 2003
  2. Eric B.
    Replies:
    1
    Views:
    433
    Jim Gibson
    Dec 17, 2004
  3. VSK
    Replies:
    2
    Views:
    2,307
  4. =?iso-8859-1?B?bW9vcJk=?=

    Matching abitrary expression in a regular expression

    =?iso-8859-1?B?bW9vcJk=?=, Dec 1, 2005, in forum: Java
    Replies:
    8
    Views:
    851
    Alan Moore
    Dec 2, 2005
  5. GIMME
    Replies:
    3
    Views:
    11,974
    vforvikash
    Dec 29, 2008
Loading...

Share This Page