« duben 2005 »
PoÚtStČtSoNe
    
 
       
Today

Navigation

Speaker Profile
Roumen's Weblog
Login
Sun Bloggers
Technorati Profile

Am I popular?

Today's Page Hits: 1232

Contacts

Name: Roman Strobl
E-mail: roman dot strobl
at sun dot com

NetBeans

Java Sites

Javalobby
The Server Side
Java Tips
Java Blogs
java.net
java.sun.com
java.cz

Blogs

NetBeans:
Geertjan
Brian Leonard
Gregg Sporar
Lukas Hasik
Ludovic Champenois
Vincent Brabant
Alexis Moussine-Pouchkine
Jullion-Ceccarelli
Tom Ball
Tim Boudreau
Jesse Glick
Petr Blaha
Ruth Kusterer
Jara Uhrik
xzajo
Jan Lahoda
James Branam
nbextras.org

Sun:
Kazem - bug cartoons ;-)
Tor Norbye
Romain Guy
James Gosling
Chief Gaming Officer
Bill Vass
Jim Grisanzio
Jonathan Schwartz

Planets:
Planet Netbeans
Planet Sun
Planet Eclipse

Other:
netbeans-blog.org
Joel Spolsky
Bruce Eckel

License info

Creative Commons License
This work is licensed under a Creative Commons License.

Recent Entries

Map of visits

Locations of visitors to this page
« Previous day (Apr 9, 2005) | Main | Next day (Apr 10, 2005) »
20050410 Neděle duben 10, 2005
Another Regexp Trick in NetBeans

Question: How do I replace two newlines by one in the whole file?

Answer: Not trivial :-) We've added regexp support recently into NetBeans (see my other post about back-references). You can certainly use "\n" in the Find What field. Now you want to replace "\n\n" by "\n". If you try to do this, it doesn't work, because the Replace With field converts \n to just n (not to a newline). Too bad we can't use this kind of expressions in the Replace With field but we have to live with that for now.

But! You can use a back-reference to get the \n into the Replace With field like this:


Using this neat trick you can replace two newlines by one. It can be used not only for newlines, but any other similar expressions starting by backslash.


    Disclaimer: The contents of my blog represent my personal opinions which may differ from official views of my employer, Sun Microsystems.