Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-14-2015, 06:01 AM
vinci vinci is offline match any number of spaces after a paragaph (^p) Mac OS X match any number of spaces after a paragaph (^p) Office for Mac 2011
Novice
match any number of spaces after a paragaph (^p)
 
Join Date: Nov 2013
Location: Romania
Posts: 5
vinci is on a distinguished road
Default match any number of spaces after a paragaph (^p)

Hello,



I've been searching the internet to find out how I can use regular expressions to delete the spaces that start a line, using the ^p.

If I have a document with a random number of spaces at the beginning of some lines, I can't use both ^p and {1,} (with a space before {1,}), because ^p doesn't support the wildcard option. Of course, I wouldn't want to start matching the highest amount of spaces and then decrease it gradually. I'd like to match any number of spaces at the beginning of lines.

How could I do that?

Thank you!
Reply With Quote
  #2  
Old 07-14-2015, 08:08 AM
Robert2 Robert2 is offline match any number of spaces after a paragaph (^p) Windows 8 match any number of spaces after a paragaph (^p) Office 2007
Competent Performer
 
Join Date: Jun 2013
Posts: 174
Robert2 will become famous soon enoughRobert2 will become famous soon enough
Default

Use a wildcard Find/Replace with the following:
Find What: ^13 {1,}
Replace With: ^13
Reply With Quote
  #3  
Old 07-14-2015, 03:17 PM
macropod's Avatar
macropod macropod is offline match any number of spaces after a paragaph (^p) Windows 7 64bit match any number of spaces after a paragaph (^p) Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,369
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You can do that with a wildcard Find/Replace using:
Find What: ^13[ ]{1,}
Replace With: ^p
You should not use ^13 for the replacement.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 07-14-2015, 03:32 PM
Robert2 Robert2 is offline match any number of spaces after a paragaph (^p) Windows 8 match any number of spaces after a paragaph (^p) Office 2007
Competent Performer
 
Join Date: Jun 2013
Posts: 174
Robert2 will become famous soon enoughRobert2 will become famous soon enough
Default

Quote:
Originally Posted by macropod View Post
You should not use ^13 for the replacement.
@macropod
Why such a stern pronouncement? Both ^13 and ^p work fine in the Replace With box in Word 2007. Have things changed in Word 2011 for Mac?
Reply With Quote
  #5  
Old 07-14-2015, 03:35 PM
vinci vinci is offline match any number of spaces after a paragaph (^p) Mac OS X match any number of spaces after a paragaph (^p) Office for Mac 2011
Novice
match any number of spaces after a paragaph (^p)
 
Join Date: Nov 2013
Location: Romania
Posts: 5
vinci is on a distinguished road
Default

Quote:
Originally Posted by Robert2 View Post
Use a wildcard Find/Replace with the following:
Find What: ^13 {1,}
Replace With: ^13
Could you please explain what ^13 means exactly? Why is it exactly 13 and not another number? What do they symbolize exactly? Thanks!

Later edit: Ok, so it's the same with ^p, but it works with wildcards, now I get it.

@macropod:
So you mean to say that it works with ^p in the replace tab, even though the wildcard option is turned on?

Another later edit: Well, it works with ^p, but it also works with ^13, so I'd tend to ask you the same question as Robert did.
Reply With Quote
  #6  
Old 07-14-2015, 04:01 PM
Robert2 Robert2 is offline match any number of spaces after a paragaph (^p) Windows 8 match any number of spaces after a paragaph (^p) Office 2007
Competent Performer
 
Join Date: Jun 2013
Posts: 174
Robert2 will become famous soon enoughRobert2 will become famous soon enough
Default

For unexplained reasons, ^13 is the code that has to be used in the Find What box to search for Paragraph Marks when the “Use wildcards” option is ON. Have a look at https://support.office.com/en-SG/article/replace-text-using-wildcards-5cda8b1b-2feb-45a6-af0e-824173d3d6e4]Use codes to find letters, formatting, fields, or special characters. However, and as far as I am aware, both ^13 and ^p can be used in the Replace With box, irrespective of whether the “Use wildcards” option is ON or OFF. I personally use ^13 in both boxes not to complicate things needlessly.
Reply With Quote
  #7  
Old 07-14-2015, 04:04 PM
macropod's Avatar
macropod macropod is offline match any number of spaces after a paragaph (^p) Windows 7 64bit match any number of spaces after a paragaph (^p) Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,369
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

^13 and ^p are not the same. ^13 can result in the insertion of a ¶ symbol that looks like a paragraph break but isn't.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 07-14-2015, 11:20 PM
Robert2 Robert2 is offline match any number of spaces after a paragaph (^p) Windows 8 match any number of spaces after a paragaph (^p) Office 2007
Competent Performer
 
Join Date: Jun 2013
Posts: 174
Robert2 will become famous soon enoughRobert2 will become famous soon enough
Default

Quote:
Originally Posted by macropod View Post
^13 and ^p are not the same. ^13 can result in the insertion of a ¶ symbol that looks like a paragraph break but isn't.
@macropod
In Word 2007 at least, ^13 does not result in the insertion of a pilcrow sign (HTML decimal entity 182). ^13 in the Replace With box actually inserts a non-printing formatting paragraph end mark that can later be found by placing ^13 in the Find What box. The Paragraph Marks inserted through ^13 in the Replace With box do not print. They are genuine non-printing formatting paragraph end marks.

If you know of cases when this is untrue, please give detailed examples.
Reply With Quote
  #9  
Old 07-15-2015, 12:03 AM
macropod's Avatar
macropod macropod is offline match any number of spaces after a paragaph (^p) Windows 7 64bit match any number of spaces after a paragaph (^p) Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,369
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Robert2 View Post
If you know of cases when this is untrue, please give detailed examples.
How about doing a bit of research for yourself. The behaviour is well-enough documented...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 07-15-2015, 12:42 AM
Robert2 Robert2 is offline match any number of spaces after a paragaph (^p) Windows 8 match any number of spaces after a paragaph (^p) Office 2007
Competent Performer
 
Join Date: Jun 2013
Posts: 174
Robert2 will become famous soon enoughRobert2 will become famous soon enough
Default

Quote:
Originally Posted by macropod View Post
How about doing a bit of research for yourself. The behaviour is well-enough documented...
Despite what you so nicely imply, I have already researched this abundantly. And I haven’t found anything to substantiate your assertion regarding this topic. On the contrary, at Special characters you can use with Find and Replace in Word I found this:

The following characters can be used in both the Find what and Replace with boxes:
^13 or ^p Carriage return/paragraph mark

This page was written to support Office 2003. Have things changed since? Where does it say so?
Please be a little bit more helpful!
Reply With Quote
  #11  
Old 07-15-2015, 12:48 AM
macropod's Avatar
macropod macropod is offline match any number of spaces after a paragaph (^p) Windows 7 64bit match any number of spaces after a paragaph (^p) Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,369
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Perhaps you should look a little harder. A web search for:
Word wildcard replace ^13
quickly turned up these three articles.

First we have Miscrosoft's own Find and replace text by using regular expressions (Advanced) article at:
https://support.office.com/en-US/Art...8-85b0ad1c427f
which says:
Quote:
Misusing the ^13 code in a replace operation can essentially convert your document into a file that you cannot format.
Then there's the MVP article Finding and replacing characters using wildcards, at:
http://word.mvps.org/FAQs/General/UsingWildcards.htm
which says:
Quote:
If you use ^13 in a replace string, invalid characters, that look like paragraph marks but aren't, will be inserted – so beware!
Yet another article, Find and Replace using wildcards, at:
http://www.gmayor.com/replace_using_wildcards.htm
says:
Quote:
^p DOES NOT WORK in wildcard search strings! It must however be used in replacement strings, but when searching, you must look for the substitute code ^13.
This advice pre-dates even Word 2000 and is still current, as the MS article demonstrates.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #12  
Old 07-15-2015, 10:10 AM
Robert2 Robert2 is offline match any number of spaces after a paragaph (^p) Windows 8 match any number of spaces after a paragaph (^p) Office 2007
Competent Performer
 
Join Date: Jun 2013
Posts: 174
Robert2 will become famous soon enoughRobert2 will become famous soon enough
Default

OK. I stand corrected.
Thanks, macropod.
Reply With Quote
Reply

Tags
regex, word 2011

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
match any number of spaces after a paragaph (^p) Two spaces after a period mysterytramp Word 14 11-06-2017 02:01 PM
match any number of spaces after a paragaph (^p) Reference number and cross reference for equation numbers to match the thesis format wmac Word 1 05-14-2013 08:54 PM
Invalid Pattern Match Value for Replacing Spaces sleake Word 2 04-26-2013 11:26 AM
paragaph hard break, soft break and ...strange break czomberzdaniela Word 2 12-03-2010 06:58 PM
Spaces After Each Word jnutella Word 0 03-04-2009 02:00 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:17 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft