Test whether a string is in a list with variablePackage to test whether a string is in a listTesting membership in a listTest whether token list is emptyUsing string variable with LaTeXString test, with complicated argumentsString test, with an OR connectorArbitrary string assigned to variable?use string variable as format string in begintabuHow to test whether pic text is empty in TiKZ?Select largest value from a list of variables in LaTeXPackage to test whether a string is in a listConditional to test whether in an itemize
I want to write a blog post building upon someone else's paper, how can I properly cite/credit them?
How does jetBlue determine its boarding order?
Convert a huge txt-file into a dataset
why it is 2>&1 and not 2>>&1 to append to a log file
Good introductory book to type theory?
A♭ major 9th chord in Bach is unexpectedly dissonant/jazzy
Concatenate all values of the same XML element using XPath/XQuery
Which "exotic salt" can lower water's freezing point by 70 °C?
Why did Gendry call himself Gendry Rivers?
Is it safe to keep the GPU on 100% utilization for a very long time?
Why can’t you see at the start of the Big Bang?
Antivirus for Ubuntu 18.04
Scaling rounded rectangles in Illustrator
Gift for mentor after his thesis defense?
Assuming a normal distribution: what is the sd for a given mean?
HTML folder located within IOS Image file?
GitLab account hacked and repo wiped
Translation of "invincible independence"
cd ` command meaning and how to exit it?
Why is there a cap on 401k contributions?
Test whether a string is in a list with variable
What is more safe for browsing the web: PC or smartphone?
While drilling into kitchen wall, hit a wire - any advice?
Is there an idiom that means that a clothe fits perfectly?
Test whether a string is in a list with variable
Package to test whether a string is in a listTesting membership in a listTest whether token list is emptyUsing string variable with LaTeXString test, with complicated argumentsString test, with an OR connectorArbitrary string assigned to variable?use string variable as format string in begintabuHow to test whether pic text is empty in TiKZ?Select largest value from a list of variables in LaTeXPackage to test whether a string is in a listConditional to test whether in an itemize
Based on this question, I'd like the following
newcommandwordPaul
newcommandbutnotJoe
IfStringInListwordGeorge,John,Paul,RingoBeat itRoll it
IfStringInListbutnotGeorge,John,Paul,RingoBeat itRoll it
to return Beat it
and Roll it
.
This has in principle been answered here but only with the help of 2 packages. It should, however, be possible much simpler with the solution here, only that I couldn't figure out how to expand the macro? (Not even with the help of this reference :/ )
conditionals expansion strings
add a comment |
Based on this question, I'd like the following
newcommandwordPaul
newcommandbutnotJoe
IfStringInListwordGeorge,John,Paul,RingoBeat itRoll it
IfStringInListbutnotGeorge,John,Paul,RingoBeat itRoll it
to return Beat it
and Roll it
.
This has in principle been answered here but only with the help of 2 packages. It should, however, be possible much simpler with the solution here, only that I couldn't figure out how to expand the macro? (Not even with the help of this reference :/ )
conditionals expansion strings
add a comment |
Based on this question, I'd like the following
newcommandwordPaul
newcommandbutnotJoe
IfStringInListwordGeorge,John,Paul,RingoBeat itRoll it
IfStringInListbutnotGeorge,John,Paul,RingoBeat itRoll it
to return Beat it
and Roll it
.
This has in principle been answered here but only with the help of 2 packages. It should, however, be possible much simpler with the solution here, only that I couldn't figure out how to expand the macro? (Not even with the help of this reference :/ )
conditionals expansion strings
Based on this question, I'd like the following
newcommandwordPaul
newcommandbutnotJoe
IfStringInListwordGeorge,John,Paul,RingoBeat itRoll it
IfStringInListbutnotGeorge,John,Paul,RingoBeat itRoll it
to return Beat it
and Roll it
.
This has in principle been answered here but only with the help of 2 packages. It should, however, be possible much simpler with the solution here, only that I couldn't figure out how to expand the macro? (Not even with the help of this reference :/ )
conditionals expansion strings
conditionals expansion strings
asked 4 hours ago
fuenfundachtzigfuenfundachtzig
4,827123858
4,827123858
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Essentially a one liner with expl3
:
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewDocumentCommandIfStringInListmmmm
clist_if_in:neTF #2 #1 #3 #4
prg_generate_conditional_variant:Nnn clist_if_in:nn ne T,F,TF
ExplSyntaxOff
begindocument
newcommandwordPaul
newcommandbutnotJoe
IfStringInListwordGeorge,John,Paul,RingoBeat itRoll it
IfStringInListbutnotGeorge,John,Paul,RingoBeat itRoll it
enddocument
With e
we force full expansion of the first argument.
By the way, e
expansion is a big achievement in TeX Live 2019, available with all TeX engines. Since you're talking of strings, I suppose that the material in the search string is fully expandable to characters.
Oooh,e
-type expansion!
– Joseph Wright♦
4 hours ago
@JosephWright I like to be modern. ;-)
– egreg
4 hours ago
add a comment |
Like this?
documentclassarticle
makeatletter
newcommand*IfStringInList[2]%
in@,#1,,#2,%
ifin@
expandafter@firstoftwo
else
expandafter@secondoftwo
fi
makeatother
begindocument
newcommandwordPaul
newcommandbutnotJoe
edeftmpnoexpandIfStringInListwordGeorge,John,Paul,RingoBeat itRoll it
noexpandIfStringInListbutnotGeorge,John,Paul,RingoBeat itRoll it%
tmp
enddocument
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
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
);
);
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%2ftex.stackexchange.com%2fquestions%2f489502%2ftest-whether-a-string-is-in-a-list-with-variable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Essentially a one liner with expl3
:
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewDocumentCommandIfStringInListmmmm
clist_if_in:neTF #2 #1 #3 #4
prg_generate_conditional_variant:Nnn clist_if_in:nn ne T,F,TF
ExplSyntaxOff
begindocument
newcommandwordPaul
newcommandbutnotJoe
IfStringInListwordGeorge,John,Paul,RingoBeat itRoll it
IfStringInListbutnotGeorge,John,Paul,RingoBeat itRoll it
enddocument
With e
we force full expansion of the first argument.
By the way, e
expansion is a big achievement in TeX Live 2019, available with all TeX engines. Since you're talking of strings, I suppose that the material in the search string is fully expandable to characters.
Oooh,e
-type expansion!
– Joseph Wright♦
4 hours ago
@JosephWright I like to be modern. ;-)
– egreg
4 hours ago
add a comment |
Essentially a one liner with expl3
:
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewDocumentCommandIfStringInListmmmm
clist_if_in:neTF #2 #1 #3 #4
prg_generate_conditional_variant:Nnn clist_if_in:nn ne T,F,TF
ExplSyntaxOff
begindocument
newcommandwordPaul
newcommandbutnotJoe
IfStringInListwordGeorge,John,Paul,RingoBeat itRoll it
IfStringInListbutnotGeorge,John,Paul,RingoBeat itRoll it
enddocument
With e
we force full expansion of the first argument.
By the way, e
expansion is a big achievement in TeX Live 2019, available with all TeX engines. Since you're talking of strings, I suppose that the material in the search string is fully expandable to characters.
Oooh,e
-type expansion!
– Joseph Wright♦
4 hours ago
@JosephWright I like to be modern. ;-)
– egreg
4 hours ago
add a comment |
Essentially a one liner with expl3
:
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewDocumentCommandIfStringInListmmmm
clist_if_in:neTF #2 #1 #3 #4
prg_generate_conditional_variant:Nnn clist_if_in:nn ne T,F,TF
ExplSyntaxOff
begindocument
newcommandwordPaul
newcommandbutnotJoe
IfStringInListwordGeorge,John,Paul,RingoBeat itRoll it
IfStringInListbutnotGeorge,John,Paul,RingoBeat itRoll it
enddocument
With e
we force full expansion of the first argument.
By the way, e
expansion is a big achievement in TeX Live 2019, available with all TeX engines. Since you're talking of strings, I suppose that the material in the search string is fully expandable to characters.
Essentially a one liner with expl3
:
documentclassarticle
usepackagexparse
ExplSyntaxOn
NewDocumentCommandIfStringInListmmmm
clist_if_in:neTF #2 #1 #3 #4
prg_generate_conditional_variant:Nnn clist_if_in:nn ne T,F,TF
ExplSyntaxOff
begindocument
newcommandwordPaul
newcommandbutnotJoe
IfStringInListwordGeorge,John,Paul,RingoBeat itRoll it
IfStringInListbutnotGeorge,John,Paul,RingoBeat itRoll it
enddocument
With e
we force full expansion of the first argument.
By the way, e
expansion is a big achievement in TeX Live 2019, available with all TeX engines. Since you're talking of strings, I suppose that the material in the search string is fully expandable to characters.
edited 4 hours ago
answered 4 hours ago
egregegreg
739k8919393270
739k8919393270
Oooh,e
-type expansion!
– Joseph Wright♦
4 hours ago
@JosephWright I like to be modern. ;-)
– egreg
4 hours ago
add a comment |
Oooh,e
-type expansion!
– Joseph Wright♦
4 hours ago
@JosephWright I like to be modern. ;-)
– egreg
4 hours ago
Oooh,
e
-type expansion!– Joseph Wright♦
4 hours ago
Oooh,
e
-type expansion!– Joseph Wright♦
4 hours ago
@JosephWright I like to be modern. ;-)
– egreg
4 hours ago
@JosephWright I like to be modern. ;-)
– egreg
4 hours ago
add a comment |
Like this?
documentclassarticle
makeatletter
newcommand*IfStringInList[2]%
in@,#1,,#2,%
ifin@
expandafter@firstoftwo
else
expandafter@secondoftwo
fi
makeatother
begindocument
newcommandwordPaul
newcommandbutnotJoe
edeftmpnoexpandIfStringInListwordGeorge,John,Paul,RingoBeat itRoll it
noexpandIfStringInListbutnotGeorge,John,Paul,RingoBeat itRoll it%
tmp
enddocument
add a comment |
Like this?
documentclassarticle
makeatletter
newcommand*IfStringInList[2]%
in@,#1,,#2,%
ifin@
expandafter@firstoftwo
else
expandafter@secondoftwo
fi
makeatother
begindocument
newcommandwordPaul
newcommandbutnotJoe
edeftmpnoexpandIfStringInListwordGeorge,John,Paul,RingoBeat itRoll it
noexpandIfStringInListbutnotGeorge,John,Paul,RingoBeat itRoll it%
tmp
enddocument
add a comment |
Like this?
documentclassarticle
makeatletter
newcommand*IfStringInList[2]%
in@,#1,,#2,%
ifin@
expandafter@firstoftwo
else
expandafter@secondoftwo
fi
makeatother
begindocument
newcommandwordPaul
newcommandbutnotJoe
edeftmpnoexpandIfStringInListwordGeorge,John,Paul,RingoBeat itRoll it
noexpandIfStringInListbutnotGeorge,John,Paul,RingoBeat itRoll it%
tmp
enddocument
Like this?
documentclassarticle
makeatletter
newcommand*IfStringInList[2]%
in@,#1,,#2,%
ifin@
expandafter@firstoftwo
else
expandafter@secondoftwo
fi
makeatother
begindocument
newcommandwordPaul
newcommandbutnotJoe
edeftmpnoexpandIfStringInListwordGeorge,John,Paul,RingoBeat itRoll it
noexpandIfStringInListbutnotGeorge,John,Paul,RingoBeat itRoll it%
tmp
enddocument
answered 1 hour ago
marmotmarmot
124k6161305
124k6161305
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX 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%2ftex.stackexchange.com%2fquestions%2f489502%2ftest-whether-a-string-is-in-a-list-with-variable%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