SOLVED! regular expressions to delete everything in braces?
Monday, November 30th, 2020 10:38 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Solved! The expression is \{[^}]*\}
thanks sonia!
I'm writing collaboratively with plain text files. I enclose my comments in braces (aka curly brackets). Here's what my commented text looks like:
{beginning of a comment.}
Lorem Ipsum has been the industry's {how can something that old be a "standard"?} dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it.{I think the bulk of this paragraph should be deleted:
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.} It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
So: sometimes comments are on their own lines, sometimes they're in the middle of a paragraph, and sometimes they enclose a paragraph.
What's the grep/regular expression pattern that deletes all content between braces and then deletes the braces themselves? (I'm on a Mac using a lovely GUI-ish utility called RegExRX, PCRE v8.42.)
(no subject)
Date: 2020-11-30 06:03 pm (UTC)Here's the pattern that worked for me. Let me know how it goes for you.
Zippity doo dah!
Date: 2020-12-01 12:20 am (UTC)That works a treat. One case didn't work because I broke the rules--I nested a
and that's exactly how it should behave.
Would you like some jewelry?
Re: Zippity doo dah!
Date: 2020-12-01 01:37 am (UTC)While I like your jewelry and appreciate the offer, I will humble-brag that the first expression I typed into the app worked, so it's not like I put a lot of time in. Happy to share knowledge without a tangible reward. :-)
Also, I noticed that was a very thoughtfully formed question! All I had to do was drop your pre-supplied test data into the app.
Re: Zippity doo dah!
Date: 2020-12-01 06:42 am (UTC)Re: Zippity doo dah!
Date: 2020-12-01 06:33 pm (UTC)Re: Zippity doo dah!
Date: 2020-12-01 06:52 pm (UTC)I know that regex are awesome, and I've had 'em my to-learn list since 1989. Yesterday I faced the fact that I'm too well-medicated to learn grep, and am so glad to have generous, brag-worthy experts like you on my d-roll.
(Thanks. Having supplied tech support (however basic) I know an example speaks louder than a question when the issue is one I already know I haven't understood.)
Are you currently slinging code (I assume f2f bodywork is out of the question for the present.)
(no subject)
Date: 2020-11-30 06:30 pm (UTC)...works on the first example, but not the second because sed doesn't have any way (that I know of) to make a substitute command work across line boundaries. ISTR Perl does, using the /s suffix and assuming you've sucked the entire file into a string. Your utility might have something similar, allowing it to treat end-of-line as an ordinary character.
Otherwise you need a loop something like the following vaguely Perlish:
(no subject)
Date: 2020-11-30 07:42 pm (UTC)(no subject)
Date: 2020-12-01 12:21 am (UTC)Thanks so much for providing these samples!
I'd be delighted to make some jewelry for you/your fam if they're interested?
(no subject)
Date: 2020-12-01 05:48 pm (UTC)I don't think anyone in my household needs jewelry at the moment (Colleen would be the only one, and I think her jewelry cabinet has been opened maybe twice since we moved in three years ago.
What kind of jewelry do you make?
(no subject)
Date: 2020-12-01 07:25 pm (UTC)Strung beads, mostly -- https://jesse-the-k.dreamwidth.org/tag/okideas+beadwork (as well as next post)
(no subject)
Date: 2020-12-01 11:48 pm (UTC)