![]() |
#1
|
|||
|
|||
![]()
Hello to all.
I'd like to ask if Word 2007 (or any application you might be aware of) has a feature which will allow me to rename a string within a text file. For example, I have the following: global.test_1 = 1\2\3\sample_1.xxx global.test_2 = 1\2\3\sample_2.xxx global.test_3 = 1\2\3\sample_3.xxx which I'd like to rename as: FTEST(global.test_1) FTEST(global.test_2) FTEST(global.test_3) Note that there are a couple hundred of such items that I'd like to rename. How would I go about doing so without extensive copy-pasting? I've tried googling for the solution but have been unsuccessful thus far. Thank you for any help. |
#2
|
||||
|
||||
![]()
You could do this with a wildcard Find/Replace, where:
Find = (global.test_[0-9]{1,})*^13 Replace = FTEST(\1)^p
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Thank you for the quick reply macropod.
So I used the Find/Replace function (Ctrl+F), and in the Replace tab, did the following: . In the Find What field: (global.test_[0-9]{1,})*^13 . Ticked the "Use wildcards" option under Search Options . In the Replace With field: FTEST(\1)^p . Clicked Replace All Unfortunately, I get a message telling me that 0 replacements were made. Am I doing something wrong is there another way to do this? Thanks! |
#4
|
||||
|
||||
![]()
All I can go on is what you posted, which implies your document contains a series of paragraphs, worded along the lines of:
global.test_1 = 1\2\3\sample_1.xxx global.test_2 = 1\2\3\sample_2.xxx global.test_3 = 1\2\3\sample_3.xxx If that is not the case - even if the capitalisation of global.test differs - nothing will be found.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]()
Thank you for reply macropod.
I am currently testing to see if the function works (hence the test names). If I use a freshly opened document and copy paste those three lines and follow your procedure, I still get 0 replacements. |
#6
|
||||
|
||||
![]()
Without actually seeing the actual file you're working on, it can be difficult for anyone to diagnose the issue. Can you attach a file to a post with some representative data (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
![]()
Sure. The attachment should be there.
Thanks. |
#8
|
||||
|
||||
![]()
Your document contains a mix of manual line breaks and paragraph breaks. Accordingly, the Find/Replace should have treated the content as a single match and have replaced the lot with:
FTEST(global.test_1) For your attachment's content, you could use a wildcard Find/Replace, where: Find = (global.test_[0-9]{1,})*([^13^l]) Replace = FTEST(\1)\2
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
![]()
Thanks for the reply macropod.
I believe I did see all lines being replaced with FTEST(global.test_1). The breaks you're talking about must have been causing issues before. For the attachment, the second command appears to have worked! However, the first string seems to not have changed. What I have now is: global.test_1 = 1\2\3\sample_1.xxx FTEST(global.test_2) FTEST(global.test_3) This was done in the attachment. Is there any reason why the first line remains unchanged? Thanks. |
#10
|
||||
|
||||
![]() Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#11
|
|||
|
|||
![]()
Thank you macropod. It works as intended.
Additionally, instead of numbers [0-9], I tried testing with letters [a-z] and was glad to see it worked well on that front as well. This has been quite useful so much thanks for all your help! |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
PRA007 | Word VBA | 13 | 11-01-2015 11:20 PM |
how do I search the content of excel files for text strings | soren | Excel | 2 | 03-19-2015 09:42 AM |
![]() |
Marrick13 | Word | 2 | 04-29-2012 05:12 AM |
Renaming slide titles | ragzdaddy | PowerPoint | 0 | 12-26-2011 01:18 PM |
![]() |
vikrantkale | Word | 1 | 03-28-2011 06:13 PM |