![]() |
#1
|
|||
|
|||
![]() 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! |
#2
|
|||
|
|||
![]()
Use a wildcard Find/Replace with the following:
Find What: ^13 {1,} Replace With: ^13 |
#3
|
||||
|
||||
![]()
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] |
#4
|
|||
|
|||
![]()
@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? |
#5
|
|||
|
|||
![]() Quote:
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. |
#6
|
|||
|
|||
![]()
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.
|
#7
|
||||
|
||||
![]()
^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] |
#8
|
|||
|
|||
![]() Quote:
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. |
#9
|
||||
|
||||
![]()
How about doing a bit of research for yourself. The behaviour is well-enough documented...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#10
|
|||
|
|||
![]() Quote:
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! |
#11
|
||||
|
||||
![]()
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:
http://word.mvps.org/FAQs/General/UsingWildcards.htm which says: Quote:
http://www.gmayor.com/replace_using_wildcards.htm says: Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#12
|
|||
|
|||
![]()
OK. I stand corrected.
Thanks, macropod. |
![]() |
Tags |
regex, word 2011 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
mysterytramp | Word | 14 | 11-06-2017 02:01 PM |
![]() |
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 |