Selective Replace in Search and Replace

M

msnyc07

I need to search and replace in a large document. I don't want to replace the
entire search term/expression just part of it. In this case I am searching
for a paragraph return followed by any letter (not digit) and then want to
change that to paragraph/tab but keep the letter. The search looks like this

^p^$

but naturally if replace is



^p^t

I lose the first letter of the text string which I don't want

How can I construct either search and replace so that



^p

Alexander

turns into

^p

^tAlexander

and not

^p

^tlexander



Thanks in advance!
 
J

Jay Freedman

You can use a wildcard replacement
(http://www.gmayor.com/replace_using_wildcards.htm).

Use the search term

([^13])([A-Za-z])

and the replacement term

\1^t\2


However, if what you're trying to achieve is an indent at the start of
each paragraph, then don't do it by adding a tab. Instead, modify the
paragraph style to include a first-line indent.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
M

msnyc07

Awesome and perfect thank you. Now I understand the concept as well :)

I do need the tab, I was trying to export to Excel as a two column sheet but
a few of my several thousand items did not have product #s before them and I
didn't want them to inadvertently end up AS product #s.

Thanks again!!!

Jay Freedman said:
You can use a wildcard replacement
(http://www.gmayor.com/replace_using_wildcards.htm).

Use the search term

([^13])([A-Za-z])

and the replacement term

\1^t\2


However, if what you're trying to achieve is an indent at the start of
each paragraph, then don't do it by adding a tab. Instead, modify the
paragraph style to include a first-line indent.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

I need to search and replace in a large document. I don't want to replace the
entire search term/expression just part of it. In this case I am searching
for a paragraph return followed by any letter (not digit) and then want to
change that to paragraph/tab but keep the letter. The search looks like this

^p^$

but naturally if replace is



^p^t

I lose the first letter of the text string which I don't want

How can I construct either search and replace so that



^p

Alexander

turns into

^p

^tAlexander

and not

^p

^tlexander



Thanks in advance!
.
 
M

msnyc07

FYI that concept came in handy immediately.

A large # of the records I imported into the word doc initially it turns out
for some reason didn't parse a Return so I ended up with

Record1Record2

instead of

Record1
Record2

So I did

([a-z])([A-Z])
\1^p\2

and solved it in 10 seconds vs the hours of frustration I'd have ordinarily
faced.

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top