Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2007

Tip: Looking for answers? Try searching our database.

regular expression

Thread view: 
gaurav v bagga - 17 Jan 2007 17:18 GMT
hi all,

 i am new to regular expression finding it difficult to write one for
".." and "..."

i'll appreciate if any one provides me with one :)

regards
gaurav
Randolf Richardson - 17 Jan 2007 18:27 GMT
> hi all,
>
>   i am new to regular expression finding it difficult to write one for
> ".." and "..."
>
>  i'll appreciate if any one provides me with one :)

    The period is a wildcard.  Use the following to quote the quoting  
character so that it will be quoted:

        "\\.\\." and "\\.\\.\\."

    Also, highly recommended reading:  
http://www.mindprod.com/jgloss/regex.html

Signature

Randolf Richardson - kingpin+nntp@lumbercartel.ca
The Lumber Cartel, local 42 (Canadian branch)
http://www.lumbercartel.ca/

gaurav v bagga - 18 Jan 2007 05:04 GMT
hi,

thanks for reply
but
StringBuffer limit= new StringBuffer("");
a2[1]="..";
limit.append(a2[1].replaceFirst("[\\.\\.]", ","));

doesn't work for me
instead of ".."=>","
i get
",."

!!!!!!!

regards
gaurav
Hendrik Maryns - 18 Jan 2007 11:26 GMT
gaurav v bagga schreef:
> hi,
>
[quoted text clipped - 5 lines]
>
> doesn't work for me

Of course not.  Why did you put the brackets in there?  Did you read the
link Randolf gave you?  The brackets mean: either of the symbols in
here.  So [\\\.\\.] means: a dot or a dot, i.e. a dot.  That is, the
first dot is found and gets replaced.  If you want both dots, just
remove the brackets.

> instead of ".."=>","
> i get
>  ",."

For a good introduction to regular expressions, I suggest you read
perlretut (google for it).  It is written for Perl, but Java has almost
the same syntax, except for the quoting oddities (i.e. everywhere you
need \ in Perl, you need \\ in Java).

H.
- --
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.