Replace first character on fourth line in every file
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Replace first character on fourth line in every file
I hope someone can help me. I have approx 1200 files and I need to change the first character in line 4 of every file to a new value. For instance, every file has a '1' in the first character of line 4, and I need to change this to a '5'. How can I do this? I am fairly new to Textpad and have not used anything more than the global Find and Replace tool so far.
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
This works in TextPad:
Search for: (.*)\n(.*)\n(.*)\n1
Replace with: \1\n\2\n\3\n5
The strings above changes from this:
To this:
-----------------------------
Use the following settings:
-----------------------------------------
[X] Regular expression
Replace All
-----------------------------------------
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
-----------------------------------------
Search for: (.*)\n(.*)\n(.*)\n1
Replace with: \1\n\2\n\3\n5
The strings above changes from this:
Code: Select all
line 1
line 2
line 3
1 line 4
line 5
line 6
line 7
1 line 8
line 9
line 10
line 11
1 line 12
line 13
line 14
Code: Select all
line 1
line 2
line 3
5 line 4
line 5
line 6
line 7
5 line 8
line 9
line 10
line 11
5 line 12
line 13
line 14
Use the following settings:
-----------------------------------------
[X] Regular expression
Replace All
-----------------------------------------
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
-----------------------------------------
Hope this was helpful.............good luck,
Bob
Bob
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
The OP wants to change the first character in line 4 of every file, not the first character in every 4th line of every file. That is not possible in TextPad using its rather weak regular expression engine alone. (It should be possible in WildEdit, but it's not, because of a bug (\A should match the beginning of the file, but it matches the beginning of every line).)
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact: