A? question? about? regular? expressions?, Take? 2?

Discussion in 'Java' started by Covington Bradshaw, Dec 17, 2006.

  1. Hi every one,

    I have a basic regular expressions question.
    It goes like this: How do I extract a sequence of
    @-delimited characters from a text?

    Example: @{1}.*?@{1}
    Will give:
    123456789abcdefhghij
    When applied to the following text:
    @123456789abcdefghij@987654321stuvwxyz@

    However I am trying to build a regular expression
    for the more complex case that will also handle the
    escape character for @ which the double @@. Consequently
    I need to know how to extract

    123456789@@abcdefhghij

    from

    @123456789@@abcdefghij@987654321@@stuvwxyz@

    using regular expressions.

    Thanks
    Covington Bradshaw, Dec 17, 2006
    #1
    1. Advertising

  2. Covington Bradshaw

    Chris Smith Guest

    Covington Bradshaw <> wrote:
    > However I am trying to build a regular expression
    > for the more complex case that will also handle the
    > escape character for @ which the double @@.


    Ah, I think I see what you mean. How about:

    @([^@]|((@@)*))@

    The result will be in group 1.

    It would be nice if you'd provided this information in your existing
    thread rather than starting a new one.

    --
    Chris Smith
    Chris Smith, Dec 17, 2006
    #2
    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. Jay Douglas
    Replies:
    0
    Views:
    600
    Jay Douglas
    Aug 15, 2003
  2. ASP.Confused

    Question on regular expressions

    ASP.Confused, Jul 26, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    377
    ASP.Confused
    Jul 26, 2004
  3. jeffM
    Replies:
    3
    Views:
    385
    Alan Moore
    Feb 2, 2004
  4. Replies:
    9
    Views:
    490
    Roedy Green
    Jan 23, 2006
  5. Noman Shapiro
    Replies:
    0
    Views:
    232
    Noman Shapiro
    Jul 17, 2013
Loading...

Share This Page