regex on fixed length string, replacing one character
-
I have a text file with a number of entries that are 32 characters in lenght and end with a <
\w{32}<
as the search string is working fine to locate them
What I want to do is inside this string, replace one of the characters with another, so say a 0 with a 5Not sure how I need to do to find that to carry the change out
Thanks in advance
-
I think you need to be a bit more specific on what you want to do. Maybe show some concrete examples. It’s probably doable, but to go on the info provided would probably be difficult and maybe wouldn’t get you the real solution you need.
-
@poyntzj said:
replace one of the characters with another
If I understand correctly you want to change the character
0
with a5
ONLY
if the line length isEXACTLY
32
characters long with a<
following.When a problem gets complicated consider breaking it down into steps. At first glance I would:
- use the current search string that works to
ALSO
tag the line with special characters, either at the start or start and end, say possibly a%
character. - create another search (replace) regex to
ONLY
work on the lines with these special characters to replace the0
with a5
as your example suggests.
I hope that gives you an idea.
Terry
- use the current search string that works to