Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using Regex

 
ramesh akula
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 22113
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Henry Wong
author
Marshal
Pie
Posts: 22113
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, got a bit too fancy there. Here is a much simpler version...



Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic