aspose file tools*
The moose likes Beginning Java and the fly likes using Regex Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "using Regex" Watch "using Regex" New topic
Author

using Regex

ramesh akula
Greenhorn

Joined: Mar 18, 2007
Posts: 1
hi
i have one text document(*.txt) file it contains some rows and columns
my requirement is that i have to remove some rows in that file

for example : ( my text file contain the below data)
---------------------------
N10 X-10.256 Y23.675
N11 X-23.563 Y45.078
N12 X34.567
N13 Y-56.774
N14 X-34.876 Y-23.878 F100
----------------------------
i want to delete sequence numbers that is N10,N11,N12,N13,N14.
so using REGEX can we do something ???

please helpme out
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18138
    
  39

Ramesh,

I would highly recommend that you pick up a book about regular expressions (or google for a tutorial). Regular expressions are incredibly powerful, and can't really be learned easily with examples.

But to answer your question... assuming that you have one line of the file in a string, here is how regex can be used to remove the first field...



Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18138
    
  39

Okay, got a bit too fancy there. Here is a much simpler version...



Henry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using Regex
 
Similar Threads
Retrieving Picture Drawn
java regex
while loop question
Brackets [ ] in regular expression
how to compare the values in arrays