As a newbie, I've been trying to find some stuff on this but am bewildered!
I have a bunch of text files (200+) with tab-delimited data like that below (with \t added to show the tabs). Each file has up to 30000 lines of data all in the same format but I want to delete the Field with addresses ie the data I've highlighted in bold between tabs 8 and 9 (eg 65 Roads Ave H on line 1 and 25 Street 6 on line 2) across all the files.
I just can't work out the regex and I'd be very grateful for any suggestions. TextPad is great but their helpfiles do not help much! Thanks
Smith\tPeter\tM\t26020\t213\t300\t1\ta\t65 Roads AveH\t130556\tNorthern
Wilson\tJ M\tM\t20059\t214\t301\t2\tb\t25 Street 6\t130556\tWestern
deleting specific parts of a line
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
-
- Posts: 7
- Joined: Tue Apr 24, 2012 7:49 pm
replace only the tab
so if I only wanted to replace say the 8th tab with a character like "-", would I enter this regex?
Find what: ^(([^\t]*\t){5})[^\t]*\t
Replace with: \-
damn but regex are confusing!
Find what: ^(([^\t]*\t){5})[^\t]*\t
Replace with: \-
damn but regex are confusing!
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
No. You would use something like
If a subexpression of a regex is parenthesised, the text it matches is captured and can be used in the replacement. The parentheses are numbered from left to right by the position of their left parenthesis symbols. In the replacement expression, \1 represents what was captured by the first parenthesised expression, \2 represents what was captured by the second, and so on.Find what: ^(([^\t]*\t){7}[^\t]*)\t
Replace with: \1-
-
- Posts: 7
- Joined: Tue Apr 24, 2012 7:49 pm