On 01/18/2019, at 14:45, Cecily Walker <[email protected]
<mailto:[email protected]>> wrote:
> I'm really struggling with Grep and trying to write a pattern that deletes 3
> spaces at the beginning of each line.
Hey Cecily,
I tend to write patterns like that this way:
^ {3}
OR
^[ ]{3}
Surrounding the space with a class helps make it pop out when you read it.
{3} is an enumerator that means 3 of the character or group before it.
> I have the text of a recipe file that was formerly a numbered list (HTML).
> When I copied the text, it retained the spaces. I'd like to remove the spaces
> at the beginning of every line. What is the correct pattern to make this
> happen?
What I'd probably start with is something more generic:
^\h+|\h+$
^ == Start of line
\h == Horizontal whitespace
+ == One or more
| == OR
\h == Horizontal whitespace
+ == One or more
$ == End of line
This will strip leading and trailing whitespace from each line.
Only when I have cases where there's other spacing I need to keep will I get
specific like the first couple of patterns.
I have BBEdit Text Filters written that do many of these jobs, and a couple of
keystrokes gets me to them.
I also have many saved regular expressions in Typinator, so I have quick access
to them.
--
Best Regards,
Chris
--
This is the BBEdit Talk public discussion group. If you have a
feature request or need technical support, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <https://www.twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.