Padding a missing line

41 views
Skip to first unread message

Tim A

unread,
Nov 26, 2021, 8:25:59 AM11/26/21
to BBEdit Talk
I've got 500 triples with name, phone, membership - but some are missing the phone number. How can I substitute a newline for missing phone numbers so all will be uniform triples as below...

Given:
Name1
415-123-4567
Joint
Name2
415-123-4568
Single
Name3
Joint
Name4
415-123-4569
Single


Want:
Name1
415-123-4567
Joint
Name2
415-123-4568
Single
Name3

Joint
Name4
415-123-4569
Single


Thanks

Kaveh

unread,
Nov 26, 2021, 9:14:55 AM11/26/21
to bbe...@googlegroups.com
Is "Joint" or "Single" the only words that can be on line after phone number?


--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://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 bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/3af55e2d-eed7-4669-b907-3ef10c255a75n%40googlegroups.com.


--
Kaveh Bazargan PhD
Director
Accelerating the Communication of Research

Tim A

unread,
Nov 26, 2021, 11:10:38 AM11/26/21
to BBEdit Talk
On Friday, November 26, 2021 at 6:14:55 AM UTC-8 Kaveh wrote:
Is "Joint" or "Single" the only words that can be on line after phone number?

There are a few more...here's the complete set:
Joint
Joint Lifetime
Joint Non-resident
Joint Senior
Senior Single
Single
Single Lifetime
Single Non-resident
 

jj

unread,
Nov 26, 2021, 3:28:11 PM11/26/21
to BBEdit Talk
Hi Tim,

Find:

(?<!\d{3}-\d{3}-\d{4})\n(Joint|Joint Lifetime|Joint Non-resident|Joint Senior|Senior Single|Single|Single Lifetime|Single Non-resident)$

Replace:

\n\n\1

HTH

Jean Jourdain

Kaveh

unread,
Nov 26, 2021, 3:56:10 PM11/26/21
to bbe...@googlegroups.com
Seems to work. Here it is on regex101

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://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 bbedit+un...@googlegroups.com.

Bucky Junior

unread,
Nov 26, 2021, 5:25:05 PM11/26/21
to BBEdit Talk
I just LOVE BBEdit’s Pattern Playground.

File -> New -> Pattern Playground

Bucky Junior

unread,
Nov 26, 2021, 5:25:06 PM11/26/21
to BBEdit Talk
I just LOVE BBEdit’s Pattern Playground

File -> New -> Pattern Playground
On Nov 26, 2021, at 1:55 PM, Kaveh <ka...@rivervalleytechnologies.com> wrote:

Kaveh

unread,
Nov 26, 2021, 5:36:21 PM11/26/21
to bbe...@googlegroups.com
I really must start using that. I am aware it's an important bit I am missing... Thanks for the reminder, Bucky.

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://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 bbedit+un...@googlegroups.com.

Tim A

unread,
Nov 26, 2021, 8:10:51 PM11/26/21
to BBEdit Talk

Thanks all! This was great. It encouraged me to wrestle with negative lookbehind, spot some problems (the phone numbers had format variations) and make some simplifications. Here is what I came up with:


Find:          (?<!\d|\()\n(Joint.*|Senior.+|Single.*)$           any line that begins with a digit or left parenthesis is a phone number

Replace:    \n\n\1

Kaveh

unread,
Nov 27, 2021, 2:59:00 AM11/27/21
to bbe...@googlegroups.com
I really must start using that. I am aware it's an important bit I am missing... Thanks for the reminder

On Fri, 26 Nov 2021 at 22:25, Bucky Junior <buckyju...@gmail.com> wrote:
--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://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 bbedit+un...@googlegroups.com.

Kaveh

unread,
Nov 27, 2021, 3:03:11 AM11/27/21
to bbe...@googlegroups.com
Good work Tim. And your solution ensures any slight variations like double spaces are also caught. 

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://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 bbedit+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages