Format Latex [option]package pairs into usepackage[option]{package}sed into csv formatRegex this question...

Is it possible to fly backward if you have a 'really strong' headwind?

How do free-speech protections in the United States apply in public to corporate misrepresentations?

How to decline a wedding invitation from a friend I haven't seen in years?

Longest bridge/tunnel that can be cycled over/through?

How to safely destroy (a large quantity of) valid checks?

Is it a bad idea to to run 24 tap and shock lands in standard

Traversing Oceania: A Cryptic Journey

Is it safe to change the harddrive power feature so that it never turns off?

Who won a Game of Bar Dice?

Who enforces MPAA rating adherence?

Artificer Creativity

Why we don’t make use of the t-distribution for constructing a confidence interval for a proportion?

US doctor working in Tripoli wants me to open online account

Why can I traceroute to this IP address, but not ping?

How do you say "homebrewer" in Spanish?

Is using 'echo' to display attacker-controlled data on the terminal dangerous?

Why not invest in precious metals?

Getting UPS Power from One Room to Another

With Ubuntu 18.04, how can I have a hot corner that locks the computer?

Live action TV show where High school Kids go into the virtual world and have to clear levels

What aircraft was used as Air Force One for the flight between Southampton and Shannon?

Ability To Change Root User Password (Vulnerability?)

Non-aqueous eyes?

Bb13b9 confusion



Format Latex [option]package pairs into usepackage[option]{package}


sed into csv formatRegex this question format into LaTeXRemoving non-printable characters using POSIX sedregex - Searching for only character pairsUse sed to format paragraphs for latexsed to change dns log string formatHow to extract delimited blocks of text from a file and have munpack decode them?extracting strings from LaTeX filesRegex to format files outputHow to remove Inverse match pairs?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I currently have a set of default LaTeX packages I use frequently formatted as follows:



package1
[options]package2
[options]package3
package4
...


I would like to be able to convert this to standard LaTeX notation of usepackage[options]{package} or usepackage{package} depending on whether the package has additional options. I have successfully created a sed/regex command to convert the lines with options, but it misses the packages without options.



echo "[option]package" | sed 's/.*([[^]]*])(.*)/\usepackage1{2}/'
>> usepackage[option]{package}


When this is run on a line with just a package, it fails (as I would expect).



echo "package" | sed 's/.*([[^]]*])(.*)/\usepackage1{2}/'
>> package


Is this a regex problem and if so, how should I approach it? I am fairly new to regex, but to me, this seems like something it can handle.










share|improve this question







New contributor



Cydmium is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


























    0















    I currently have a set of default LaTeX packages I use frequently formatted as follows:



    package1
    [options]package2
    [options]package3
    package4
    ...


    I would like to be able to convert this to standard LaTeX notation of usepackage[options]{package} or usepackage{package} depending on whether the package has additional options. I have successfully created a sed/regex command to convert the lines with options, but it misses the packages without options.



    echo "[option]package" | sed 's/.*([[^]]*])(.*)/\usepackage1{2}/'
    >> usepackage[option]{package}


    When this is run on a line with just a package, it fails (as I would expect).



    echo "package" | sed 's/.*([[^]]*])(.*)/\usepackage1{2}/'
    >> package


    Is this a regex problem and if so, how should I approach it? I am fairly new to regex, but to me, this seems like something it can handle.










    share|improve this question







    New contributor



    Cydmium is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      0












      0








      0








      I currently have a set of default LaTeX packages I use frequently formatted as follows:



      package1
      [options]package2
      [options]package3
      package4
      ...


      I would like to be able to convert this to standard LaTeX notation of usepackage[options]{package} or usepackage{package} depending on whether the package has additional options. I have successfully created a sed/regex command to convert the lines with options, but it misses the packages without options.



      echo "[option]package" | sed 's/.*([[^]]*])(.*)/\usepackage1{2}/'
      >> usepackage[option]{package}


      When this is run on a line with just a package, it fails (as I would expect).



      echo "package" | sed 's/.*([[^]]*])(.*)/\usepackage1{2}/'
      >> package


      Is this a regex problem and if so, how should I approach it? I am fairly new to regex, but to me, this seems like something it can handle.










      share|improve this question







      New contributor



      Cydmium is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I currently have a set of default LaTeX packages I use frequently formatted as follows:



      package1
      [options]package2
      [options]package3
      package4
      ...


      I would like to be able to convert this to standard LaTeX notation of usepackage[options]{package} or usepackage{package} depending on whether the package has additional options. I have successfully created a sed/regex command to convert the lines with options, but it misses the packages without options.



      echo "[option]package" | sed 's/.*([[^]]*])(.*)/\usepackage1{2}/'
      >> usepackage[option]{package}


      When this is run on a line with just a package, it fails (as I would expect).



      echo "package" | sed 's/.*([[^]]*])(.*)/\usepackage1{2}/'
      >> package


      Is this a regex problem and if so, how should I approach it? I am fairly new to regex, but to me, this seems like something it can handle.







      sed regular-expression






      share|improve this question







      New contributor



      Cydmium is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share|improve this question







      New contributor



      Cydmium is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share|improve this question




      share|improve this question






      New contributor



      Cydmium is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      asked 1 hour ago









      CydmiumCydmium

      1




      1




      New contributor



      Cydmium is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      New contributor




      Cydmium is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























          1 Answer
          1






          active

          oldest

          votes


















          2














          Please verify if this works for you:



          $ echo -e "[options]package3npackage4" | sed 's/^([[^]]*])?(.*)/\usepackage1{2}/'
          usepackage[options]{package3}
          usepackage{package4}


          I replaced .* with ^ to match the start of line and added ? to make the brackets optional.






          share|improve this answer
























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "106"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });






            Cydmium is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f523437%2fformat-latex-optionpackage-pairs-into-usepackageoptionpackage%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            Please verify if this works for you:



            $ echo -e "[options]package3npackage4" | sed 's/^([[^]]*])?(.*)/\usepackage1{2}/'
            usepackage[options]{package3}
            usepackage{package4}


            I replaced .* with ^ to match the start of line and added ? to make the brackets optional.






            share|improve this answer




























              2














              Please verify if this works for you:



              $ echo -e "[options]package3npackage4" | sed 's/^([[^]]*])?(.*)/\usepackage1{2}/'
              usepackage[options]{package3}
              usepackage{package4}


              I replaced .* with ^ to match the start of line and added ? to make the brackets optional.






              share|improve this answer


























                2












                2








                2







                Please verify if this works for you:



                $ echo -e "[options]package3npackage4" | sed 's/^([[^]]*])?(.*)/\usepackage1{2}/'
                usepackage[options]{package3}
                usepackage{package4}


                I replaced .* with ^ to match the start of line and added ? to make the brackets optional.






                share|improve this answer













                Please verify if this works for you:



                $ echo -e "[options]package3npackage4" | sed 's/^([[^]]*])?(.*)/\usepackage1{2}/'
                usepackage[options]{package3}
                usepackage{package4}


                I replaced .* with ^ to match the start of line and added ? to make the brackets optional.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 1 hour ago









                FreddyFreddy

                4,2031420




                4,2031420






















                    Cydmium is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    Cydmium is a new contributor. Be nice, and check out our Code of Conduct.













                    Cydmium is a new contributor. Be nice, and check out our Code of Conduct.












                    Cydmium is a new contributor. Be nice, and check out our Code of Conduct.
















                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f523437%2fformat-latex-optionpackage-pairs-into-usepackageoptionpackage%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                    Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                    Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...