Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I need a regex one liner for the following problem.
If There is multiple paragraph after a Line which has ::, Then have to put + between each paragraph.
Current Text
Code:
One dollar:: and eighty-seven cents. That was all. And sixty cents of it was in pennies.
Thee:: It was easy to spot her. All you needed to do was look at her socks.
One would reach her knee while the other barely touched her ankle.
While the argument:: seems to be different the truth is it's always the same.
They both knew it, but neither has the courage or strength.
The words:: hadn't flowed from his fingers for the past few weeks.
He didn't understand why he couldn't even type a single word.
Was being satisfied enough?
She reached her goal:: exhausted. Even more chilling to her was that the euphoria that she thought she'd feel.
Spending time at national parks can be an exciting adventure.
It seemed like it should have been so simple.
Was it enough:: That was the question he kept asking himself.
He knew that he was satisfied and he also knew it wasn't going to be enough.
It was just a burger. Why couldn't she understand that?
Yes, he had promised her and yes, he had broken that promise.
Expected Output
Code:
One dollar:: and eighty-seven cents. That was all. And sixty cents of it was in pennies.
Thee:: It was easy to spot her. All you needed to do was look at her socks.
+
One would reach her knee while the other barely touched her ankle.
While the argument:: seems to be different the truth is it's always the same.
+
They both knew it, but neither has the courage or strength.
The words:: hadn't flowed from his fingers for the past few weeks.
+
He didn't understand why he couldn't even type a single word.
+
Was being satisfied enough?
She reached her goal:: exhausted. Even more chilling to her was that the euphoria that she thought she'd feel.
+
Spending time at national parks can be an exciting adventure.
+
It seemed like it should have been so simple.
Was it enough:: That was the question he kept asking himself.
+
He knew that he was satisfied and he also knew it wasn't going to be enough.
+
It was just a burger. Why couldn't she understand that?
+
Yes, he had promised her and yes, he had broken that promise.
No problem. There is one negative lookahead (?!…) assertion and one positive (?=…) assertion. They are useful on occasion. They are non-capturing groups. Again, see "man perlre" about that.
@others. No, it's not so easy, see Turbocapitalist's solution. The OP didn't make it clear, but lines that don't include :: are considered part of the previous paragraph.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.