Hello Anthony,

On May 25, 7:37 am, Anthony Lam <anthonycklamp...@hotmail.com> wrote:
> Hi Michele,
>
> Thanks for your response. I have tried many combinations using [] but the 
> problem still exists. Could you give me the answer to this case?  I have no 
> clue of the definition of groups, ^.\,?,[ etc. regarding formatting in here.
^ means that you begin the filter at the begin of line
$ means that you end the filter at the end of line
. means any character
\ is used for escaping character which otherwise have a meaning to the
filter (for example if you have a $ in your string, you should escape
it.
(whatever) is used to delimit group
[whatever] is used to define characters which are allowed to appear
? means one occurence of the preceeding
{n} means exactly n occurence of the preceeding
etc.

You may find useful the following urls:
http://en.wikipedia.org/wiki/Regular_expression#POSIX_Basic_Regular_Expressions
and especially this one:
http://www.regular-expressions.info/
to learn the syntax.

To find useful regexp, this site:
http://regexlib.com/

Now for your problem:
^[(]{1}\d{3}[)]{1}\d{6}$
means:
^ begin at the begin of line (that is it escapes return line feed if
any), this is important with some languages which keep in the string
the begin/end of line special characters which depend on the machine
[(] search for a parenthesis (no need to escape here because ( has no
special meaning when inside square brackets
{1} search for exactly one occurence of the preceeding, i.e. ^[(]{1},
means search for a string which begins by exactly one parenthesis and
nothing else
\d means search for a digit
\d{3} means search for three continuous digits
and the same explanation for the rest of the regexp

Unless you need to retrieve the particular digits, you don't need to
group (that is to use parenthesis).

Hope it helps

Michèle

-- 
You received this message because you are subscribed to the Google
Groups "Java EE (J2EE) Programming with Passion!" group.
To post to this group, send email to
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en

Reply via email to