• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

Removing Unwanted characters from a text file.

I figure this is a simple regex recipe, but I haven't been able to find the right one yet. I have a text file, and I want to remove all instances of 1-2 digits separated by a colon followed by 1-2 digits. So anything that looks like:

1:1
10:10
10:1
1:10
0
stakor
Asked:
stakor
1 Solution
 
Terry WoodsIT GuruCommented:
Something like this? Don't forget to back up your file before testing, though the -i.bak option should make a backup with a .bak extension.

perl -i.bak -pe 's/(?<!\d)\d\d?:\d\d?(?!\d)//g' my_input_file.txt

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now