Replace at a precise position

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Arnold McRae

Replace at a precise position

Post by Arnold McRae »

How can I replace a character at a precise position with TextPad? Let say I have a "." at column 32 and I want to replace that character only when it has been found at that position.

TIA

Arnold
Andreas

Re: Replace at a precise position

Post by Andreas »

Search for
^\(.\{31,31\}\)\..
with regex activated
and replace with
\1whateveryouwanttoreplaceforthedot

^ starts the search at start of line
with \(\) you remember what's found for replacement
with \1 you put the first \(\) content in the replacement
. finds any character
\{31,31\} says you want to find at least 31 (first value) and at most 31 (second value) times what is left of it (which is the . to match any character). Result: you find exactly 31 characters
\. finds a . (not to mix up with the "any character")

So the above expression
searches for 31 characters at the start of a line followed by a .
and replaces it with
the same 31 characters followed by whateveryouwanttoreplaceforthedot
Susan Hunt

Re: Replace at a precise position

Post by Susan Hunt »

wouldnt it be easier to:

turn word wrap off
click configure, block select mode on

to select the text to be replaced:
put your cursor on col 32 & drag it down however far u want.

click ctrl-H or search, replace
& ensure box 'selected text' is checked
put your period in the from box
ignore the to box.
click replace all
Post Reply