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;
}
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
New contributor
add a comment |
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
New contributor
add a comment |
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
New contributor
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
sed regular-expression
New contributor
New contributor
New contributor
asked 1 hour ago
CydmiumCydmium
1
1
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered 1 hour ago
FreddyFreddy
4,2031420
4,2031420
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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