I'm trying to do a simple find and replace BUT I need to restrict
it to a specific column.
e.g replace all 7's with 6's in column 252.
I couldn't figure it out so I did it via a macro instead.
Still very curious how it should be done.
Perl would do it via something like : $temp =~ s/(.{251})7(.*)/$1 6 $2/;
Is it along those lines ?
Appreciate any suggestions
thanks
regex query
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
Hello larnapairce....................
Need to replace all 7s in column 252 with 6s?
Try this:
Search for: \(^.\{251\}\)7
Replace with: \16
================================
Explanation of RegEx Search Section:
\( = beginning of first grouping to isolate
^ = start at beginning of line
. = any character, space, etc.
\{251\} = exact number of previous character (.)
\) = end of first grouping
7 = digit seven
=============================
Explanation of RegEx Replace Section:
\1 = first group in Search Section
6 = digit 6
Common English:
Starting at the beginning of the line, look for a group of any 251 characters followed immediately with a 7. Replace that group with the same information followed by a 6.
OR
Replace any 7 in column 252 with a 6.
=============================
Hope this helps...........good luck,
Bob
Need to replace all 7s in column 252 with 6s?
Try this:
Search for: \(^.\{251\}\)7
Replace with: \16
================================
Explanation of RegEx Search Section:
\( = beginning of first grouping to isolate
^ = start at beginning of line
. = any character, space, etc.
\{251\} = exact number of previous character (.)
\) = end of first grouping
7 = digit seven
=============================
Explanation of RegEx Replace Section:
\1 = first group in Search Section
6 = digit 6
Common English:
Starting at the beginning of the line, look for a group of any 251 characters followed immediately with a 7. Replace that group with the same information followed by a 6.
OR
Replace any 7 in column 252 with a 6.
=============================
Hope this helps...........good luck,
Bob
Last edited by Bob Hansen on Wed Aug 13, 2003 2:56 pm, edited 1 time in total.
-
- Posts: 3
- Joined: Tue Aug 12, 2003 2:39 pm