1

It appears that MS Word accepts regular expressions for finding and replacing strings. I would like to use regex to add carriage returns to a block of text, in order to parse out individual lines.

starting text:

  1. (Previously Presented): something here 9. (Previously Presented):other thing here 12. (Previously Presented): another example 16. (Previously Presented): more text

desired end text:

  1. (Previously Presented): something here

  2. (Previously Presented):other thing here

  3. (Previously Presented): another example

  4. (Previously Presented): more text

I have succeeded in getting MS Word to match the desired strings with the following expression

[0-9]{1,2}\. \(

however, I haven’t been able to write a proper matching string that modifies the match and adds two carriage returns. I have tried all of these with no success:

^p^p\1

^p^p\0

^p^p$0

^p^p$1

^p^p$&

the closest I can get returns a result like this, with all the numbers deleted.

Previously Presented): something here

Previously Presented):other thing here

Previously Presented): another example

Previously Presented): more text

Please let me know if I have overlooked something, and if this is actually possible in Word.

Thanks!

1

Word doesn't accept ^p in regular expressions, you need to use ^13 instead. So your replace with field will be: ^13^13\1

  • thanks for your suggestion. I tested both ^p and ^13, which provide the same result. to clarify, I'm having trouble with the "\1" part of the replace expression. Word deletes it entirely, but I need it to be included in the replace text. – user3489590 Apr 22 '15 at 10:30
  • \1 backreference only part of the find expression, especially the one within the first pair of brackets. If you don't have brackets it will not put anything. Try to match ([0-9]{1,2}\. \() – Máté Juhász Apr 22 '15 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.