Replace/Erase substring of a word

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I am trying to find words with bold format and delete the substring [0,5] of
all occurences
All words are longer then 5 letters.
I am able to find the words with the format but I cannot delete the substing.
Is it possible to type something like [6]* in the replace field to keep the
letter 6 and higher in the word?
Any suggestions?
 
Thanks Greg
I did as you mentioned but it did not work.

I tried to search
?{5}(*>)

and replace it with
\1




Greg Maxey said:
Try

More>Use Wildcards

Find: ?{5}(*>)
Replace with \1

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

Hi
I am trying to find words with bold format and delete the substring
[0,5] of all occurences
All words are longer then 5 letters.
I am able to find the words with the format but I cannot delete the
substing. Is it possible to type something like [6]* in the replace
field to keep the letter 6 and higher in the word?
Any suggestions?
 
Did you set the format in the find field to "Bold."

It should work if I understand your objective. Find words in bold and
delete first five characters.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

Thanks Greg
I did as you mentioned but it did not work.

I tried to search
?{5}(*>)

and replace it with
\1




Greg Maxey said:
Try

More>Use Wildcards

Find: ?{5}(*>)
Replace with \1

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

Hi
I am trying to find words with bold format and delete the substring
[0,5] of all occurences
All words are longer then 5 letters.
I am able to find the words with the format but I cannot delete the
substing. Is it possible to type something like [6]* in the replace
field to keep the letter 6 and higher in the word?
Any suggestions?
 
Yes I did as you mentioned.
Even though if I did not change the Find field to bold it should have
deleted the first five characters of words with normal format?



Greg Maxey said:
Did you set the format in the find field to "Bold."

It should work if I understand your objective. Find words in bold and
delete first five characters.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

Thanks Greg
I did as you mentioned but it did not work.

I tried to search
?{5}(*>)

and replace it with
\1




Greg Maxey said:
Try

More>Use Wildcards

Find: ?{5}(*>)
Replace with \1

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Julian wrote:
Hi
I am trying to find words with bold format and delete the substring
[0,5] of all occurences
All words are longer then 5 letters.
I am able to find the words with the format but I cannot delete the
substing. Is it possible to type something like [6]* in the replace
field to keep the letter 6 and higher in the word?
Any suggestions?
 
Julian,

Hmm,,try Find: <*{4}(*>)
Replace: \1

If this doesn't work, show me an example of what should be found and what it
should look like afterwards.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

Yes I did as you mentioned.
Even though if I did not change the Find field to bold it should have
deleted the first five characters of words with normal format?



Greg Maxey said:
Did you set the format in the find field to "Bold."

It should work if I understand your objective. Find words in bold
and delete first five characters.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

Thanks Greg
I did as you mentioned but it did not work.

I tried to search
?{5}(*>)

and replace it with
\1




:

Try

More>Use Wildcards

Find: ?{5}(*>)
Replace with \1

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Julian wrote:
Hi
I am trying to find words with bold format and delete the
substring [0,5] of all occurences
All words are longer then 5 letters.
I am able to find the words with the format but I cannot delete
the substing. Is it possible to type something like [6]* in the
replace field to keep the letter 6 and higher in the word?
Any suggestions?
 
Hi

Example 1
Word without format
Word before: stronger
Word after: er

Example2
A whole line with bold format
Line before: My name is Julian
Line after: me is Julian

Is the expression
<*{4}(*>)
going to mark the first 4 characters in every word in the text even when you
use the expression just for searching words?

Greg Maxey said:
Julian,

Hmm,,try Find: <*{4}(*>)
Replace: \1

If this doesn't work, show me an example of what should be found and what it
should look like afterwards.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

Yes I did as you mentioned.
Even though if I did not change the Find field to bold it should have
deleted the first five characters of words with normal format?



Greg Maxey said:
Did you set the format in the find field to "Bold."

It should work if I understand your objective. Find words in bold
and delete first five characters.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Julian wrote:
Thanks Greg
I did as you mentioned but it did not work.

I tried to search
?{5}(*>)

and replace it with
\1




:

Try

More>Use Wildcards

Find: ?{5}(*>)
Replace with \1

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Julian wrote:
Hi
I am trying to find words with bold format and delete the
substring [0,5] of all occurences
All words are longer then 5 letters.
I am able to find the words with the format but I cannot delete
the substing. Is it possible to type something like [6]* in the
replace field to keep the letter 6 and higher in the word?
Any suggestions?
 
Julian,

You are changing the rules in the middle of the game ;-)

You said nothing about whole lines in your original post or about changing
non-bolded text.

The last code I sent you would convert

Stronger stronger stronger stronger

to: "stronger er stronger er" if the second and fouth words where
formatted to bold.

If you want the "find" isolated to "bold" text only, then you have to put
the cursor in the find field and press More>format>font>bold.





--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

Hi

Example 1
Word without format
Word before: stronger
Word after: er

Example2
A whole line with bold format
Line before: My name is Julian
Line after: me is Julian

Is the expression
<*{4}(*>)
going to mark the first 4 characters in every word in the text even
when you use the expression just for searching words?

Greg Maxey said:
Julian,

Hmm,,try Find: <*{4}(*>)
Replace: \1

If this doesn't work, show me an example of what should be found and
what it should look like afterwards.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

Yes I did as you mentioned.
Even though if I did not change the Find field to bold it should
have deleted the first five characters of words with normal format?



:

Did you set the format in the find field to "Bold."

It should work if I understand your objective. Find words in bold
and delete first five characters.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Julian wrote:
Thanks Greg
I did as you mentioned but it did not work.

I tried to search
?{5}(*>)

and replace it with
\1




:

Try

More>Use Wildcards

Find: ?{5}(*>)
Replace with \1

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Julian wrote:
Hi
I am trying to find words with bold format and delete the
substring [0,5] of all occurences
All words are longer then 5 letters.
I am able to find the words with the format but I cannot delete
the substing. Is it possible to type something like [6]* in the
replace field to keep the letter 6 and higher in the word?
Any suggestions?
 
Hi Greg
I will tell you the whole story now.

I have a big document which has several heading levels
Heading1, Heading2, Heading3

The Headings are numbered manually which means that if you add or delete a
heading the correct heading number will not be updated.
What I want to do is to delete all the manually added numbers in the
beginning of each heading and add automatic numbering format.
The only problem is how to delete the numbers which each heading starts with.

Example1
heading3 before: 1.2.2 Technical specification
heading3 after: Technical specification













Greg Maxey said:
Julian,

You are changing the rules in the middle of the game ;-)

You said nothing about whole lines in your original post or about changing
non-bolded text.

The last code I sent you would convert

Stronger stronger stronger stronger

to: "stronger er stronger er" if the second and fouth words where
formatted to bold.

If you want the "find" isolated to "bold" text only, then you have to put
the cursor in the find field and press More>format>font>bold.





--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

Hi

Example 1
Word without format
Word before: stronger
Word after: er

Example2
A whole line with bold format
Line before: My name is Julian
Line after: me is Julian

Is the expression
<*{4}(*>)
going to mark the first 4 characters in every word in the text even
when you use the expression just for searching words?

Greg Maxey said:
Julian,

Hmm,,try Find: <*{4}(*>)
Replace: \1

If this doesn't work, show me an example of what should be found and
what it should look like afterwards.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Julian wrote:
Yes I did as you mentioned.
Even though if I did not change the Find field to bold it should
have deleted the first five characters of words with normal format?



:

Did you set the format in the find field to "Bold."

It should work if I understand your objective. Find words in bold
and delete first five characters.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Julian wrote:
Thanks Greg
I did as you mentioned but it did not work.

I tried to search
?{5}(*>)

and replace it with
\1




:

Try

More>Use Wildcards

Find: ?{5}(*>)
Replace with \1

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Julian wrote:
Hi
I am trying to find words with bold format and delete the
substring [0,5] of all occurences
All words are longer then 5 letters.
I am able to find the words with the format but I cannot delete
the substing. Is it possible to type something like [6]* in the
replace field to keep the letter 6 and higher in the word?
Any suggestions?
 
Try this ;-)

Sub Test()
Dim oPar As Paragraph
Dim myRng As Range
For Each oPar In ActiveDocument.Paragraphs
Select Case oPar.Style
Case "Heading 1", "Heading 2", "Heading 3"
Set myRng = oPar.Range.Duplicate
myRng.Collapse wdCollapseStart
myRng.MoveEndUntil Cset:="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
myRng.MoveEnd wdCharacter, -1
myRng.Delete
Case Else
'Do Nothing
End Select
Next oPar
End Sub
 

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

Back
Top