> Hi every one,
>
> I have a basic regular expressions question.
Yes. Can you do us a favor and respond in existing threads, instead of
starting new ones all the time? Do you know how to reply to an existing
message?
> Note the expression @([^@]|((@@)*))@ was suggested in a
> previous reply but this one returns a false positive
> on the following text:
>
> @123456789@@abc
Okay. Then try (^|[^@])@([^@]|((@@)*))@($|[^@])
This time, your result will be in group #2.

Signature
Chris Smith
Covington Bradshaw - 23 Dec 2006 23:26 GMT
public static void main(String[] args) {
Pattern pattern = Pattern.compile("(^|[^@])@([^@]|((@@)*))@($|[^@])", Pattern.DOTALL);
String b = "@123456789@@abcdefghij@987654321@@stuvwxyz@";
Matcher matcher = pattern.matcher(b);
System.out.println("find [" +matcher.find() + "]");
System.out.println("group [" + matcher.group() + "]");
System.out.println("start [" + matcher.start() + "]");
System.out.println("end [" + matcher.end() + "]");
}
This code returns 9@@a
I am expecting @123456789@@abcdefghij@
Am I missing something?
=======================
> Okay. Then try (^|[^@])@([^@]|((@@)*))@($|[^@])
>
> This time, your result will be in group #2.
Chris Smith - 24 Dec 2006 15:22 GMT
> This code returns 9@@a
>
> I am expecting @123456789@@abcdefghij@
>
> Am I missing something?
Nah. I just screwed up, and didn't realize it. This one is actually
tested:
(^|[^@])@(([^@]|(@@))+)@($|[^@])
Again, answer in group #2.

Signature
Chris Smith