text:
Do you make me up?
Introduction
Every string has an "alphabet", composed of the characters that make it up. For example, the alphabet of \$abcaabbcc\$ is \${a, b,c}\$. There are two operations you can do with alphabets: getting the alphabet of a string, and seeing if another string has a given alphabet.
Challenge
Given two strings, you must write a function that finds the alphabet of the first string, and returns a truthy or falsy value based on whether that alphabet makes up the second string, ie. if the alphabet of the first string is the same as that of the second. However, the function should also return a truthy value if the alphabet of the first string is a superset of, or contains, the alphabet of the second.

The two strings will be of variable length. They might be empty. If they are, their alphabets are considered and empty list/set. Any valid unicode string could be an input.
The function must return a truthy or falsy value. Any type of output is OK, as long as, when converted to a boolean in your language (or the equivalent), it is true.

Examples

String 1: "abcdef", String 2: "defbca"
Output: truthy
String 1: "abc", String 2: "abc123"
Output: falsy
String 1: "", String 2: ""
Output: truthy
String 1: "def", String 2: "abcdef"
Output falsy
String 1: "abcdef", String 2: "abc"
Output truthy
String 1: "", String 2: ""
Output: truthy

Rules
This is code-golf, so shortest answer in bytes wins!
The Catalogue
The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:
## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:
## [><>](https://esolangs.org/wiki/Fish), 121 bytes

/* Configuration */

var QUESTION_ID = 194869; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 8478; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });
    else console.log(body);
  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    lang = jQuery(''+lang+'').text();

    languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1;
    if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}
body {
  text-align: left !important;
  display: block !important;
}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 500px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}

<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/all.css?v=ffb5d0584c5f">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

Did you mean String 1: "abcdef", String 2: "def" for the last test case?

Test cases with repeating letters would also be good.

@Arnauld - sorry, about that, I meant the output to be falsy. I fixed it now.

Then, it's basically the same test case as the 2nd one. You should add one where the 1st alphabet is a superset of the 2nd.

Can we take the inputs in reverse order?

No,  inputs will always be in the order mentioned.

"Any valid unicode string could be an input." <-- if unicode support is mandatory, you should include some unicode test cases. (I have a feeling some existing answers will fail them.)

"However, the function should also return a truthy value if the alphabet of the first string is a superset of, or contains, the alphabet of the second." you should include a test case for this.

Recommended test case: {"", "", falsey} (Explanation:  is F0 98 9F 80 in UTF-8,  is F0 9F 80 80 in UTF-8; If an answer is checking the UTF-8 bytes instead of characters, it will return truthy)

Suggested test case: "abcdef", "acf" (which I think should be truthy if I understand the challenge correctly)? Some of the answers are incorrect for this test case.

@KevinCruijssen - ok, will do.

Python 3, 21 bytes
lambda a,b:{*a}>={*b}

Try it online!
Explanation

* to unpacks the sequence/collection into positional arguments
set >= other to test whether every element in other is in the set.

Hi, can you explain your answer ?

@DorianTurba Thanks for adding an explanation!

Haskell, 13 bytes
all.flip elem

Try it online!
Haskell doesn't have built-in set or subset functions, so we need to do it ourselves. This is a pointfree version of
17 bytes
a%b=all(`elem`a)b

Try it online!
which it itself shortened from
22 bytes
a%b=and[elem c a|c<-b]

Try it online!

Regex (ECMAScript 2018 / Pythonregex / .NET), 20 bytes
Takes the two strings in joined format, delimited by a single newline. That is why there are two newlines in the regex itself (saving 2 bytes compared to if \n were used):

((.)(?<=\2.*
.*))*$

Try it online! - ECMAScript 2018
Try it online! - Python import regex
Try it online! - .NET
It just so happens that the order of String 1 and String 2 dictated by this question is the one that makes it a bit nontrivial in regex, impossible to do without variable-length lookbehind or non-atomic lookahead. If it were the other way around, it would be possible in vanilla ECMAScript.
\n         # 1. Find the newline, so we can match against String 2
(          # 2. Start loop at the beginning of String 2
  (.)      # 3. At every iteration, capture another character from String 2 into \2
  (?<=     # 4. positive lookbehind - look backwards
    \2.*   # 6. Assert that the captured character \2 can be found in String 1
    \n.*   # 5. Find the newline, so we can match against String 1
  )
)*         # 7. Continue the loop as long as possible
$          # 8. Assert that when the loop has finished, we've reached String 2's end

Regex (Java), 29 or 27 bytes
Java has a limited sort of variable-length lookbehind. It's unlimited in length, but there are strict limits as to what is allowed in a lookbehind (most notably, all backreferences must be inside a lookahead inside the lookbehind), and stricter limits on what will actually work in a lookbehind. So in principle it has the same power as full-fledged variable-length lookbehind in its ability to solve computation problems, but will do so less efficiently.
In this case, two limits come into play: \2 need to be backreferenced in a lookahead, and apparently, if an expression like .*x.* is in a lookbehind (where x is any character), it will silently fail to work properly. Here we work around this problem by collapsing the .*\n.* into [\s\S]*:

((.)(?<=^(?=.*\2)[\s\S]*))*$

29 bytes - Try it online!
This problem could also be solved by using comma as a delimiter instead of newline:
,((.)(?<=^(?=[^,]*\2).*))*$

27 bytes - Try it online!
Or by using the s (dotall) flag with newline as the delimiter:

((.)(?<=^(?=[^
]*\2).*))*$

27 bytes - Try it online!
Regex (PCRE1), 48 bytes + s flag
It is possible to emulate variable-length lookbehind using recursive constant-width lookbehind:

((.)((?<=(?=
((?<=(?=$.|\2|(?4)).))|(?3)).)))*$

Try it online! (C++)
Try it on regex101
The recursive lookbehind goes through two stages in this regex: first (?3) to find the newline, and then (?4) to find the captured character. The regex could be 1 byte shorter if some character that is guaranteed not to be present in the input were used as the dummy impossible match instead of $..
/s single line mode (dotall) is used so that newline can be the delimiter, with the . in the lookbehinds being allowed to match it. With any other choice of delimiter (even a control character), this flag would not be needed. Therefore, I have not included it in the byte count. FWIW though, keeping newline as the delimiter and not using /s mode would require upping the length to 52 bytes (with a regex that runs much more slowly, due to putting the newline after the lookbehind), costing the same in bytes as adding (?s) would, thus not worthwhile.
Regex (PCRE2 / Perl 5), 45 bytes + s flag
Same approach as PCRE1, but the dummy impossible match $. is no longer needed to avoid a "recursive call could loop indefinitely" error:

((.)((?<=(?=
((?<=(?=\2|(?4)).))|(?3)).)))*$

Try it online! - PCRE2 (C++)
Try it online! - PCRE2 (PHP – doesn't work, and I don't know why)
Try it online! - Perl 5
Regex (PCRE2) length-limited, 39 38\$+\lfloor log_{10}L_{max}\rfloor\$ bytes
It is possible to emulate molecular lookbehind (and some of the power of variable-length lookbehind) using jaytea's lookahead quantification trick, but this limits the maximum possible length of String 2 to 1023 characters. In the linked blog post I commented (as Davidebyzero) on a way to extend this limit by a couple of orders of magnitude, but it nevertheless remains.
This trick does not work in Perl 5, because apparently it has the same "no empty optional" behavior as ECMAScript. [Edit: This isn't true in most circumstances. Needs to be looked into.]
1 byte can be saved by omitting the anchor. Any non-match will remain a non-match even if it is attempted from later positions in the first string, because if the second string isn't made up of a subset of the first string's characters, it certainly won't be made up of a smaller subset. This does result in a slowdown for non-matches.
((?=(?=.*
(\2?(.?))).*\3)){1,1023}?.*
\2$

Try it online! (C++)
Try it online! (PHP)
Regex (PCRE2) length-limited const, 36 35\$+\lfloor log_{10}L_{max}\rfloor\$ bytes
The regex still works with a constant quantifier (for a total length of 39 bytes), but will take more steps (but not necessarily much more time, depending on the optimization done by the regex engine).
((?=(?=.*
(\2?(.?))).*\3)){1149}.*
\2$

Try it online! (C++)
Try it online! (PHP)
Regex (Perl 5 / .NET / Java) length-limited const, 34 33\$+\lfloor log_{10}L_{max}\rfloor\$ bytes
This version works in Perl, in which the quantifier can go up to {32766} (which would make a regex length of 40 bytes, and still execute fast), and in Java, in which the quantifier apparently can go up to {400000000165150719} (but must be much smaller for execution time to be practical).
PCRE1 (and PCRE2 earlier than v10.35), as well as Ruby, treat any quantifer greater than 1 on a lookaround as being 1, so the lookaround must be wrapped in a dummy group, costing 2 bytes. But in Perl 5, .NET, Java, and Python 3, lookarounds can be directly quantified:
(?=(?=.*
(\1?(.?))).*\2){9999}.*
\1$

Try it online! - Perl 5
Try it online! - .NET (C#)
Try it online! - Java - 1 byte longer – needs the anchor for some reason – this needs investigation
Regex (PCRE1) length-limited, {45 or 42 44 or 41}\$+\lfloor log_{10}L_{max}\rfloor\$ bytes
Due to a fundamental flaw in PCRE1's design, a workaround is needed to prevent the regex from returning truthy when the last character of String 2 is not present in String 1:
((?=(?=.*
(\2?(.?))).*\3.*(
\2))){1,481}?.*\4$

Try it online! (C++)
Try it on regex101
The regex still works with a constant quantifier, but will take more steps (but not necessarily much more time, depending on the optimization done by the regex engine):
((?=(?=.*
(\2?(.?))).*\3.*(
\2))){500}.*\4$

Try it online! (C++)
Try it on regex101
Regex (Ruby) length-limited, 50 49\$+\lfloor log_{10}L_{max}\rfloor\$ bytes
The lookahead quantification trick fully works in Ruby, and can go as high as {100000}. There is no support for nested backreferences, so \2 must be copied to \4 in a lookahead:
((?=(?=.*
(\4?(.?))).*\3(?=.*
(\2)))){1,100000}?.*
\2$

Try it online!
While Ruby's regex engine does have subroutine calls, and thus at first glance it might appear to be possible to adapt the solutions that emulate variable-length lookbehind to it, it does not appear to be possible to do so. Any attempt at recursion with subroutine calls generates the error "never ending recursion", even when there are clear-cut terminating conditions.
Regex (Pythonregex) length-limited const, 44\$+\lfloor log_{10}L_{max}\rfloor\$ bytes
The lookahead quantification trick works in Python 3 (using the regex module rather than re), but only with a constant quantifier. This is a shame, because Python can go as high as {4294967294}, but increasing its value in this regex causes super-exponential slowdown. There is no support for nested backreferences, so just like the Ruby version, \2 must be copied to \4 in a lookahead.
(?=(?=.*
(\3?(.?))).*\2(?=.*
(\1))){300}.*
\1$

Try it online!
Regex (RegexMathEngine -xml), 27 bytes
In RegexMathEngine, molecular (non-atomic) lookahead can be used in the form of (?*...) when enabled using the -xml command line parameter ("enable extension: molecular lookahead").
This needs to be anchored because the delimiter is inside a negative lookahead, so without the anchor, a non-match could become a match by leapfrogging the delimiter and starting its match within the second string.
^(?!(?*.*,(.)+)(?!.*\1.*,))

Comma is the delimiter because it is not yet possible to work with strings containing newlines when using command-line invocation of this regex engine (which works as a one-line-at-a-time grep).
Regex (PCRE2 v10.35+), 27 24 bytes
PCRE does not have variable-length lookbehinds, but PCRE2 v10.34 has introduced non-atomic lookarounds in the form of (*napla:...) and (*naplb:...) (with the added synonyms of (?*...) and (?<*...) in v10.35), making it also able to solve this problem in the general case. This is shorter than in RegexMathEngine thanks to the use of newline as a delimiter:
^(?!(?*.*
(.)+)(?!.*\1))

Try it on regex101
Attempt This Online! (PHP)
You can change the delimiter (for example to comma: ^(?!(?*.*,(.)+)(?!.*\1.*,))), to test on the command line using pcre2grep.
If the strings were in the other order: Regex (ECMAScript / Python), 19 bytes
If String 2 comes before String 1, there is no need for lookbehind or non-atomic lookahead, and the solution is universal to all regex engines that have lookahead. It does now need to be anchored though, because otherwise, any non-match could become a match by discarding the beginning of the first string.
^((.)(?=.*
.*\2))*

Try it online! - ECMAScript
Try it online! - Python
^(          # start loop at the beginning of String 2
  (.)       # at every iteration, capture another character from String 2 into \2
  (?=.*\n   # look ahead to String 1 (by finding the newline)
    .*\2    # assert that the captured character \2 can be found in String 1
  )
)*          # continue the loop as long as possible
\n          # assert that when the loop has finished, we've reached String 2's end

Python 3, 28 23 bytes
lambda x,y:not{*y}-{*x}

Try it online!
-5 bytes thanks to Wizzwizz4
28 bytes
lambda x,y:not set(y)-set(x)

Try it online!
Simply turns the two inputs into sets and subtracts the sets from each other

If you used {*y} syntax, you could remove that space for -5 bytes.

JavaScript (ES6), 31 bytes
Takes arrays of characters as input.
a=>b=>b.every(c=>a.includes(c))

Try it online!

25 bytes
For the record, below is my original answer, which was designed for alphanumeric characters.
a=>b=>!b.match(`[^${a}]`)

Try it online!

Won't this fail if a contains a hyphen? e.g f("a-c")("abc")

@Shaggy Yes, I overlooked the any valid unicode string part. Updated.

Brachylog, 3 bytes
dp⊆

Try it online!
Takes string 1 as the output variable and string 2 as the input variable.

W, 2 bytes
Back then I definitely had the negation instruction. If you think it's boring then continue.
t!

Explanation
t  % Remove all characters of 1st input that appears in 2nd input.
   % e.g. ['abcdef','abc'] -> 'def'
 ! % Negate the result. So if the resulting string had something,
   % it will return falsy. Otherwise it will yield truthy.

W, 4 bytes
W is back, reimplemented!
t""=

If you want to specify your input and code, you look for imps.py and then re-set those variables like this:
read = ["abcabc","abc"]

prog = 't""='

Note that your inputs must be in a single array with the joined values.
Wren, 86 60 30 26 bytes
I didn't expect this. Wren is very hard to golf.
Fn.new{|a,b|b.trim(a)==""}

Try it online!
Explanation
Fn.new{                    // New anonymous function
       |a,b|               // With parameters a and b
            b.trim(a)      // After removing all characters in a that are in b
                           // (If b can be assembled using a the result should
                           // be a null string; otherwise it should be a
                           // non-empty string.
                     ==""} // Is this result an empty string?

Fn.new{ ... } is a bit verbose (comparing to (vars)=>expression) but it looks so pretty. And the "meat" is quite small (just 18 bytes)!

Never think of eating a wren. It is tiny and you can't get a lot of meat out of it despite of its attracting appearance.

Gaia, 1 byte
⊃

Try it online!
Just a built-in. For strings, it checks for character-wise superset.
Test Suite

Ruby, 21 bytes
->x,y{!y.tr(x,"")[0]}

The tr method replaces all instances of the first string it's passed with the corresponding character in the second string it's passed. So all characters from x are removed from y. If there are any characters left, then it returns the first value (all values are truthy in ruby except false and nil) and inverses it. And if there are no characters left, then nil is inversed.
Golfy Tricks Implemented:

Using y.tr(x,"") instead of y.chars-x.chars
Using !array[0] instead of array.empty?

Try it online!

Similar 20 byte answer. These both technically fail though because tr and count will do the wrong thing if ^ or - show up in the wrong place.

APL (Dyalog Unicode), 3 bytes
×/∊

Try it online!
Use it as string2 f string1.
How it works
×/∊
  ∊  Does each char of string2 appear in string1?
×/   All of them?

Switch to dzaima/APL and save a byte: ∧∊ Try it online!

Japt -!, 15 10 5 bytes
k@VøX

Try it online!
Thanks to @Shaggy for -5.

Welcome to Japt!

6 bytes, using the -! flag.

Or maybe 5 bytes

Flags are free ;)

4 bytes?

4-byte one seems broken to me and i can't figure out how to fix it @Shaggy. fixed the thing about flags though

J, 5 bytes
*/@e.

Try it online!
Is each char of the 2nd string an element of e. the 1st string?  This returns a boolean mask, whose elements we multiply together with */.  J is smart about 0 values so that if you apply */ to the empty list '' you get 1.
J, 6 bytes
''-:-.

Try it online!
Does the empty string '' match -: 1st string "set minused" -. from the 2nd?

PHP (7.4), 26 25 28 bytes
fn($a,$b)=>''>=strtok($b,$a)

Try it online!
PHP's strtok, basically removes characters of its second parameter, form its first parameter and returns the result or false if the result is empty.
By removing $a characters from $b, if the result is empty (false), we output a truthy, else a falsy.
Christoph mentioned an issue with output of '0' from strtok (which equals to false), and to solve it, ''>= is used instead of a simple NOT (!) at a cost of +3 bytes. ''== would work the same way as well.

Alternativelly, for PHP 4.1.2 and older, you can use <?=!strtok($b,$a); (18 bytes) directly, where the short_open_tag and register_globals default to 1 (enabled). For this, a POST/GET/COOKIE/SESSION would need to have the keys a and b set.

@IsmaelMiguel I prefer to forget register globals and old PHP versions. You can post it as a separate answer though.

No, thanks. Was just posting it as a reminder that PHP used to be a lot worse.

Sadly this doesn't work correctly e.g. 'abc', 'abc0a123'. strtok returns '0' which will then be transformed to true.

@Christoph Thanks, fixed.

Bracmat, 51 bytes
(f=a b.!arg:(?a,?b)&vap$((=.@(!a:? !arg ?)&|F).!b))

The function f returns a list of Fs, one F for each character in b that is not in a's alphabet. An empty list means that b's alphabet is contained in a's alphabet. The function vap splits the second argument, which must be a string, in UTF-8 encoded characters if the second argument (!b in this case) is valid UTF-8, and otherwise in bytes.
Try it online!

C (gcc), 94 85 bytes
f(a,b,c)int*a,*b,*c;{for(;*b;++b){for(c=a;*c&&*c!=*b;++c);if(!*c)return 0;}return 1;}

Try it online!
-9 bytes from JL2210
Returns int: 1 for truthy and 0 for falsey.
Note: takes two parameters that are each pointers to null-terminated wide strings (wchar_t are the same size as int on the platform used on TIO, so we can take the strings as int* instead of including wchar.h and taking them as wchar_t*)
Explanation/Ungolfed:
#include <wchar.h>
int f(const wchar_t *a, const wchar_t *b) {
    for ( ; *b != L'\0'; ++b) { // For each character in the second string
        const wchar_t *temp;
        for (temp = a; *temp != L'\0'; ++temp) {
            if (*temp == *b) break;
            // If the character is in the first string,
            // then continue and check the next character
        }
        if (*temp == L'\0') return 0;
        // If the character was not found, return 0 (falsey)
    }
    return 1; // If every character was found, return 1 (truthy)
}

85 bytes

78 bytes

@ceilingcat 74 bytes by replacing last return with a=

building on @ceilingcat 76 bytes

Lua, 75 bytes
load'b,a=...return a:gsub(".",load"return not b:find(...,1,1)and [[]]")==a'

Try it online!
Now this is a bit messy. load is used to create function here, so everything inside is its body. Here, after taking input, following transformation is done: every symbol in second string is checked in first one. If it is found, internal function return false and no replacement is done. Otherwise, symbol is removed (replaced with empty string). Resulting string is compared with one passed as input, efficiently checking that no deletions were performed.
TIO link also include test cases.

awesome golfing

Pyth, 7 bytes
g.{w.{w

Try it online!
First string on first line of input, second string on second line.

I'm pretty sure !-E works.

Submit it separately then, you'll deserve any upvotes you get for it.

Also 7 bytes

MATL, 3 bytes
wmA

Try it online! Or verify all test cases.
Explanation
The code implicitly takes two strings as inputs, swaps them, and verifies if All the characters in the first string (originally the second input) are members of the other string.
(A non-empty array containing exclusively ones is truthy in MATL. This would allow omitting A if it wasn't for the case with empty inputs).

CJam, 5 bytes
ll\-!

Try it online!
Test Suite
Explanation
ll     Read 2 lines of input
  \    Swap their order
   -   Remove from the second input all characters in the first
    !  Negate

Kotlin, 35 bytes
{a,b->(b.toSet()-a.toSet()).none()}

Try it online!

PowerShell, 34 bytes
param($a,$b)0-notin($b|%{$_-in$a})

Try it online!
Takes two arrays of chars as input.

Whispers v1, 50 43 bytes
> Input
> Input
>> {2}
>> 3⊆1
>> Output 4

Try it online!
Squeezed pseudo code:
>> Output ( Set(Input2) ⊆ Input 1)

Explanation:
As always in Whispers, we execute the last line first:
>> Output 4

Outputs the result of line 4:
>> 3⊆1

Returns a Boolean representing the result of line 3 being a subset of the result of line 1. Let's evaluate line 1 first:
>> Input

Takes the first line of the input.
Now line 3:
>> {2}

This line forms the set of the result of line 2, which takes the next line of input.
So we get the squashed pseudocode:
>> Output ( Set(Input2) ⊆ Input 1)

K (ngn/k), 5 bytes
~^&/?

Try it online!
A tacit function taking two arguments.

? find the indices of the first matches of the right-hand argument in the left-hand argument; returns 0N (null) if it's not present
&/ take the minimum
~^ is the minimum not null?

x86-16 machine code, 14 bytes
00000000: 85c9 ac57 518b caf2 ae59 5fe1 f5c3       ...WQ....Y_...

Listing:
85 C9       TEST CX, CX         ; check for empty string
        S_LOOP:
AC          LODSB               ; next char in string 2
57          PUSH DI             ; save first string pointer
51          PUSH CX             ; save first string length
8B CA       MOV  CX, DX         ; put first string length into scan counter
F2 AE       REPNZ SCASB         ; compare string 2 char to each in string 1 until match
59          POP  CX             ; restore first string length
5F          POP  DI             ; restore first string pointer
E1 F5       LOOPZ S_LOOP        ; loop until end of second string OR no matches
C3          RET                 ; return to caller

Callable function - input string 1 at [DI] length in DX, string 2 at [SI] length in CX.  Output ZF if Truthy, NZ if Falsy.
Programming note: if input string 2 is empty, it will (harmlessly) loop 65,535 times in order to correctly return ZF. This is because LOOPcc decrements before testing for 0 so it must wrap around the 16-bit counter register before reaching 0 again. Otherwise a JZ or JCXZ after the TEST would eliminate this at a cost of +2 bytes, but hey, this is Code Golf not Efficiency Golf.
Tests:

Try it online!

C (gcc), 51 bytes
f(a,b)int*a,*b;{return wcschr(a,*b)&&f(a,b+1)|!*b;}

Try it online!
In this 51 bytes version I tweaked a little bit the 53 bytes version (see below, former answer) thanks to && :

At each letter *b I check we can find it in string a.
If not, it means wcschr(a,*b) equal 0, so the program will not bother to execute the second part &&f(a,b+1) (that allows us to go deeper in the recursive) and so it return 0...
...along with !*b | NOT of pointer b: if we had arrived at the end of b, the pointer is NULL so we return 0|!NULL <=> 0|1 <=> 1. If the pointer is not NULL (which means wcschr(a,*b) previously returned NULL before string a's \0) then we return 0|!PTR <=> 0|0 <=> 0

C (gcc), 53 bytes
f(a,b)int*a,*b;{return*b&&wcschr(a,*b)?f(a,b+1):!*b;}

Try it online!
This is a recursive function

wcschr(a,*b) looks for unicode character *b in string a, return NULL character is not found, else pointer to the character (!=NULL).
We keep looking if 1/ we are not at the end of string b (*b!=NULL) and 2/ while we keep finding our char *b in string a.
If both conditions are true we inspect our next character in string b f(a,b+1)
if not we return NOT of the pointer to *b : if we had arrived at the end of b then *b is NULL and our function return true, if not it means that wcschr failed before reaching end of string b.

NB: wcschr is the builtin function equivalent of strchr (man strchr)
#include <wchar.h>
#ifndef WCSCHR
# define WCSCHR __wcschr
#endif
/* Find the first occurrence of WC in WCS.  */
wchar_t *
WCSCHR (const wchar_t *wcs, const wchar_t wc)
{
  do
    if (*wcs == wc)
      return (wchar_t *) wcs;
  while (*wcs++ != L'\0');
  return NULL;
}
libc_hidden_def (__wcschr)
weak_alias (__wcschr, wcschr)
libc_hidden_weak (wcschr)

it looks like you're reading past the end of string b in the 51 byte verion this should fix it

Jelly, 3 bytes
fƑ@

Try it online!
A dyadic link taking two strings and returning a Boolean. If the order of the input s can be reversed, I could save one byte.
Works by checking whether the second string is unchanged when filtering to just the characters in the first.

The OP has now said that the input order cannot be reversed :-/

Charcoal, 5 bytes
⬤η№θι

Try it online! Link is to verbose version of code. Outputs a Charcoal boolean, i.e. - for true, nothing for false. Explanation:
⬤       All of
 η      Second string
  №     Count (is non-zero) in
   θ    First string of
    ι   Character of second string
        Implicitly print

Zsh, 35 bytes
a=(${(s::)1})
((!${#${(s::)2}:|a}))

Try it online!
      ${(s::)2}        # split second parameter into characters
   ${          :|a}    # remove all elements of $a
   ${#            }    # count
((!                ))  # return truthy if 0, falsy if non-zero

Perl 5, 53 bytes
sub{local$_=pop;eval"y/@{[quotemeta pop]}//d";!y///c}

Try it online!

Lua, 114 bytes
d=function(a,c,v)for _,k in ipairs(a) do c[k]=v end end
function l(a,b)c={};d(b,c,1);d(a,c);return not next(c) end

Try it online!
Couldn't get it shorter with plain Lua because lightweight Lua knows few builtins. If it needs to work with strings:
Lua, 116 bytes
function d(a,c,v)for _,k in a:gmatch"." do c[k]=v end end
function l(a,b)c={};d(b,c,1);d(a,c);return not next(c) end

Try it online!

I think you can't use ipairs on strings?

@val I can't. I expect the input to be a list/table with the characters. Else it would be around ~20 bytes longer I assume.

I think it doesn't fulfill challenge requirements then: "given two strings". I like the idea tho!

@val A string essentially is a list of characters. But I could add a solution for strings too.

@val added, at the cost of two additional bytes

Wow, good job! Didn't expected it to be only two bytes away :-). Btw, I also have Lua answer here (75 bytes), although it uses entirely different way. You probably can shorten your solution by using load+vararg for functions.

Haskell, 24 bytes
f a b=all(\c->elem c a)b

Try it online!

Japt -!, 3 bytes
VkU

Try it
VkU   U = first string, V = second
Vk    Remove all characters in V
  U   that are present in U
-!    If the string is empty, return true, else false

R, 40 bytes
function(x,y,`+`=utf8ToInt)all(+y%in%+x)

Try it online!

Keg, 13 7 5 4 3 bytes
-⑫=

-1 byte due to the new ⑫ operator that pushes an empty string
Answer History
4 bytes
-``=

Try it online!
-1 byte with trailing newline
And y'all thought W could beat Keg!
This one's a bit of a stretch, as it uses a footer and header to define a function. I'll explain later.
Answer History
7 bytes (SBCS)
᠀᠀^-``=

Try it online!
-6 bytes due to the fact I realised I could just compare the result to an empty string.
Explained
᠀᠀^-``=
᠀᠀      #Take the two input strings
  ^     #Reverse stack to place strings in correct input order
   -    #Subtract the first string from the second
    ``= #Compare the result to an empty string, pushing either 1 or 0

13 bytes (SBCS)
᠀᠀^-÷!&ø&[0|1

Try it online!
Uses features from Keg, Reg and Keg+!
Explained
᠀᠀^-÷!&ø&[0|1
᠀᠀              #Take the two strings as input
  ^             #Reverse the stack so that string subtraction works
   -÷           #Subtract first input from second and item split the result
     !          #Push the length of this splitted string
      &ø&       #Safely store this length in the register while clearing the stack
         [0|1   #Push 0 if there are still items otherwise 1 if empty string

You're using a code snippet if you don't include the code defining the function.

Perl 6, 17 bytes
!(*R∖*)o**.comb

Try it online!
Also known as Raku. Anonymous code object taking two arguments and returning a boolean.
Explanation:
       **.comb   # Map each string to a list of characters
      o          # Then return if
  *R∖*           # The second argument set minus the first
!(    )          # Is empty?

C# (.NET Core), 52 bytes 46 bytes 53 bytes
static bool f(string a, string b)=>b.All(a.Contains);

Try it online!

Why not b.All(a.Contains)? Note that you have to write a function or a full program, not a snippet. Most of the time, C# answers use anonymous functions. In this case a valid answer would be a=>b=>b.All(a.Contains) (of type Func<string, Func<string, bool>>, a function that returns a function that returns the result)

Julia 1.0, 19 bytes
x\y=all(c->c∈x,y)

Try it online!
Thought I beat python till I saw xnor's answer! Uses a generator to check if every character in y exists in (∈) x. Explanation: pass an anonymous function that checks if c is in x as the predicate to all, check that it returns true for all values in y.
Previous 22 byte solution: x\y=all(c∈x for c=y)
Try it online!

Java, 90 Bytes
(String[] a)->a[1].chars().filter(x->!a[0].contains((String.valueOf((char)x)))).count()<1;

Try it online!
Not great, but chars() helps some...

You can save 2 bytes by removing whitespace and the semicolon.

05AB1E, 4 bytes
€ê`å

Try it online! or verify all test cases
Explanation
€ê    Remove duplicates and sort each input
  `   Dump alphabets to the stack
   å  Check if the 2nd alphabet is contained in the 1st one

Fails for ["abcdef", "acf"] (should be truthy, but is falsey in your program).

Clojure, 39 Bytes
(fn[a b](every? #(contains?(set a)%)b))

Try it online!

Perl 5, 46 41 39 bytes
-2 bytes thanks to dingledooper

sub{pop.'␀'.pop~~/^((.)(?=.*␀.*\2))*␀/}

Try it online!
This uses the ECMAScript / Python / universal regex from my pure regex answer (explained there). The unprintable character NUL (ASCII 0) is used as the delimiter, shown here as ␀.

Kotlin, 50 bytes
{s1:String,s2:String->s2.filter{it !in s1}.none()}

Try it online!

Welcome to the site!  How does this take input?

@PostRockGarfHunter Thanks for letting me know. I've updated the answer by adding a Try it online! link so that the solution can be tested. I hope it's OK like this, as I've seen this approach used by others.

Wolfram Language (Mathematica), 7 bytes
SubsetQ

Try it online!
SubsetQ does not account for multiplicity.

Java, 57 49 48 bytes
a->b->(b+'␀'+a).matches("((.)(?=.*␀.*\\2))*␀.*")

Try it online!
This uses the ECMAScript / Python / universal regex from my pure regex answer.
An actual NUL (ASCII 0) character is used as the delimiter for maximum universality. This is inserted directly into the TIO test harness as actual NUL characters, but displayed above using the ␀ glyph for visibility.

Vyxal, 2 bytes
F¬

Try it online or verify all test cases.

Rust, 106 104 bytes
|a:&str,b:&str|{let c=|x:&str|x.chars().collect::<std::collections::HashSet<_>>();c(b).is_subset(&c(a))}

Try it online!

-2 bytes because

On a technical level, Rust inserts
extern crate std;

into the crate root of every crate,
— Rust docs, module std::prelude

Scala, 46 bytes
(a:String,b:String)=>(b.toSet&~a.toSet)==Set()

Try it online!

Prolog (SWI), 92 bytes
e(_,[]).
e(L,[H|T]):-member(H,L),e(L,T).
f(X,Y):-string_chars(X,A),string_chars(Y,B),e(A,B).

Try it online!

Python 2.7 .pyc file, 130 bytes
Sorry, bytecode formats are just too much fun to pass up for simpler tasks
Hexdump because there's plenty of nulls :)
00000000: 03f3 0d0a fb0b 8b59 6300 0000 0000 0000  .......Yc.......
00000010: 0004 0000 0040 0000 0073 1a00 0000 7400  .....@...s....t.
00000020: 0074 0100 6302 0083 0000 8301 0003 8300  .t..c...........
00000030: 0083 0100 6b05 0046 2800 0000 0028 0200  ....k..F(....(..
00000040: 0000 7303 0000 0073 6574 7309 0000 0072  ..s....sets....r
00000050: 6177 5f69 6e70 7574 2800 0000 0028 0000  aw_input(....(..
00000060: 0000 2800 0000 0073 0000 0000 7308 0000  ..(....s....s...
00000070: 003c 6d6f 6475 6c65 3e00 0000 0073 0000  .<module>....s..
00000080: 0000                                     ..

Optimizations over the in built compiler:

Stack juggling the functions
Zero byte filename because it's valid
Crashing at the end because why spend a byte exiting cleanly

python-xdis output for the file:
# pydisasm version 4.1.0
# Python bytecode 2.7 (62211)
# Disassembled from Python 2.7.15+ (default, Jul  9 2019, 16:51:35)
# [GCC 7.4.0]
# Timestamp in code: 1502284795 (2017-08-09 13:19:55)
  0:
            LOAD_GLOBAL          (set)
            LOAD_GLOBAL          (raw_input)
            DUP_TOPX             2
            CALL_FUNCTION        0 (0 positional, 0 named)
            CALL_FUNCTION        1 (1 positional, 0 named)
            ROT_THREE
            CALL_FUNCTION        0 (0 positional, 0 named)
            CALL_FUNCTION        1 (1 positional, 0 named)
            COMPARE_OP           (>=)
            PRINT_EXPR

With bytes to make it easier to see where byte saves could be
# pydisasm version 4.1.0
# Python bytecode 2.7 (62211)
# Disassembled from Python 2.7.15+ (default, Jul  9 2019, 16:51:35)
# [GCC 7.4.0]
# Timestamp in code: 1502284795 (2017-08-09 13:19:55)
  0:           0 |74 00 00| LOAD_GLOBAL          (set)
               3 |74 00 01| LOAD_GLOBAL          (raw_input)
               6 |63 00 02| DUP_TOPX                  2
               9 |83 00 00| CALL_FUNCTION        (0 positional, 0 named)
              12 |83 00 01| CALL_FUNCTION        (1 positional, 0 named)
              15 |03      | ROT_THREE
              16 |83 00 00| CALL_FUNCTION        (0 positional, 0 named)
              19 |83 00 01| CALL_FUNCTION        (1 positional, 0 named)
              22 |6b 00 05| COMPARE_OP           (>=)
              25 |46      | PRINT_EXPR

Factor + math.unicode, 3 bytes
⊃

Try it online!
An alias for superset?.

Thunno 2 !, 1 byte
ṗ

Try it online!
Explanation
   # Implicit input
ṗ  # Set difference
   # Logical NOT
   # Implicit output


text:
Regular ASCII Polygons
There are 4 regular polygons that we can construct using ASCII art:

                              . . .
                  . . .      . . . .
  .     . . .    . . . .    . . . . .
 . .    . . .   . . . . .   . . . . .
. . .   . . .    . . . .    . . . . .
                  . . .      . . . .
                              . . .

That is, a triangle, a square, a hexagon and an octagon.
Your task is to take two inputs and produce the corresponding ASCII art polygon.
Input
The two inputs will be:

A string/list of printable ASCII characters (i.e. with code points in the range \$33\$ (!) to \$126\$ (~)
An indicator as to which polygon you should output. This indicator can be any \$4\$ distinct and consistent values (e.g. 1234, ABCD, etc.), but each must be only one character long, to avoid any exploitation of this input.

The string will be a perfect fit for the polygon, meaning that, if the shape to be outputted is:

A triangle, then the length of the string will be a triangular number
A square, then the length of the string will be a square number
A hexagon, then the length of the string will be a centered hexagonal number
An octagon, then the length of the string will be an octo number

The string may have repeated characters, but will always fit the appropriate lengths for the given shape/sequence, so there is no need to worry about too many/few characters.
Output
You should output a shape, indicated by the second input, in the format shown at the top of the challenge with the . replaced with the characters in the inputted string. Each character must be separated by a single space, and leading/trailing whitespace is acceptable, so long as the shape is preserved. The characters may be used in any order, but each character in the string must only appear once. For example, for a hexagon using ABCDABC, the following are valid:

 A B     B A
C D A   A B C
 B C     D C

as each character from the string is used once. However,

 A A    A B    AD
A A A  A B C   ABC
 A A    C A    BC

are not valid (the first only has A, the second doesn't have a D and the third doesn't have spaces between characters).
This is code-golf so the shortest code in bytes wins
Test cases
These test cases use T, S, H and O to indicate which shape the output should be in. The string of characters is on the first line and the indicator on the second
i1+K8{^wsW
O

 i 1
+ K 8
{ ^ w
 s W

,r1~vi4l{W@+r<vzP;mq>:8gJcgg$j`$RFhDV
H

   , r 1 ~
  v i 4 l {
 W @ + r < v
z P ; m q > :
 8 g J c g g
  $ j ` $ R
   F h D V

0J++
S

0 J
+ +

Kn[Vyj
T

  K
 n [
V y j

#5~m
S

# 5
~ m

'*g(AUFV~Ou2n=172s'|S11q&j=+#
O

  ' * g
 ( A U F
V ~ O u 2
n = 1 7 2
s ' | S 1
 1 q & j
  = + #

The current input spec could be abused. I could specify that a triangle should be specified as [[0,0,1,0],[0,1,0,1],[1,0,1,0,1]] for example, and so avoid the need to encode the triangle within code. Or is that ok?

@NickKennedy That is perfectly valid. However, I'd expect the community to downvote answers which violate the spirit of the challenge, such as an answer that uses that "loophole", and I certainly would downvote such a boring answer

@NickKennedy that would work for only one size string. How would a program use that input and a string of length 15?

Actually, scratch that, I found a way more abusive solution: eval. The four distinct inputs just define functions which format the four shapes. @cairdcoinheringaahing, I recommend scoring as length(code)+length(indicators); or restrict indicator to one character.

However, I'd expect the community to downvote answers which violate the spirit of the challenge, such as an answer that uses that "loophole", and I certainly would downvote such a boring answer I really do not think that we should downvote an answer to a code golf question that is both golfed and fits the defined spec!

It’s unclear, and subjective, to refer to the “spirit” of the challenge. I think it’s better to have a clear spec as to what’s allowed and what’s not

I've updated the rules on what makes a valid indicator and not to invalidate the suggested loopholes by @GammaFunction and Nick Kennedy. While it's rather restrictive, I think its better than allowing the input to be exploited to shorten the code.

@Arnauld The < and > characters didn't work with the <pre> tags. Updated to fix that

@GammaFunction's loophole is already in the standard loopholes, so wouldn't be allowed. That same loophole may or may not cover Nick Kennedy's.

Ruby, 139 138 bytes
->s,n{w=(((s=s.chars*' ').size/n=n.hex)**0.5).to_i+k=1&~n
(0..h=w+n/5*~-w).map{|i|s.slice!(0,[w+n/6*~-w,w**k+i,w+h+~i].min*2).center w*4}}

Try it online!
A function taking 2 arguments: a string s and a shape n as a single character in hexadecimal of value 1,2,6 or A. It returns an array of strings.
Explanation
The input string is converted to an array, then joined back into a string with spaces between the characters. The length of this combined string is twice the length of the original string, minus 1. This is divided by a constant, square rooted and rounded to determine the side length w of the polygon to be drawn. The value of the constant is per the table below. For triangles, the square root is rounded down. For others, it needs to be rounded up, so we round down then add k=1&~n to correct.
 Shape   Triangle  Square  Hexagon  Octagon
 n =     1         2       6        10

We iterate through h rows of output. For the triangle and square, h=w.  For the other shapes we need to add w-1 for the hexagon and twice this amount for the octagon. This is done by adding n/5*~-w.
Each line of output is centred and padded to w*4 characters which is enough for all cases. Chunks of s are removed using slice! and outputted. For the octagon the number of symbols to be outputted on each line is the minimum of three numbers: w+w-1 for the centre section, w+i for the top section and w+h-i-1 = w+h+~i for the bottom section. These formulas also work for the hexagon. Note that the numbers have to be multiplied by 2 to account for the spaces.
For the square and triangle, the width of the output is restricted to w. Therefore the formula for the centre section becomes w+n/6*~-w to cover all shapes . For the triangle, the width of the output is further restricted to 1+i. Therefore the formula for the top section becomes w**k+i to cover all shapes.

JavaScript (ES8),  191 176 174  171 bytes
Takes input as (type)(string), where the 1st parameter is 0123 instead of TSHO and the 2nd parameter is an array of characters.
i=>g=(s,n=1,p=0)=>s[o=(h=k=>k?(F=j=>j?s.slice(p,p+=w+=k&6?k&2&&1:-1).join` `.padStart(n*2+w)+`
`+F(j-1):'')(n-k%2)+h(k>>3):'')([2,4,10,106][i],w=i>1?n-1:n*i),p]?g(s,n+1):o

Try it online!
How?
The shape of each polygon is encoded as groups of 3 bits, packed into a single integer.
Each group of bits is decoded as follows:

bit 0: if set, repeat \$n-1\$ times; if cleared, repeat \$n\$ times
bits 1-2: if both bits are cleared, decrement the width at each iteration; if only bit 1 is set, increment the width after at iteration; otherwise, leave it unchanged

The initial width of the shape is:
$$w=\cases{
0,&\text{if $i=0$}\\
n,&\text{if $i=1$}\\
n-1,&\text{if $i>1$}
}$$
Triangle (\$i=0\$)
..1
.1.1
1.1.1

One group: repeat \$n\$ times, increment the width → encoded as \$2\$
Square (\$i=1\$)
1.1.1
1.1.1
1.1.1

One group: repeat \$n\$ times, leave the width unchanged → encoded as \$4\$
Hexagon (\$i=2\$)
..1.1.1
.1.1.1.1
1.1.1.1.1
.2.2.2.2
..2.2.2

Two groups:

group 1: repeat \$n\$ times, increment the width → encoded as \$2\$
group 2: repeat \$n-1\$ times, decrement the width → encoded as \$1\$

Final encoding: \$2+8\times1=10\$
Octagon (\$i=3\$)
..1.1.1
.1.1.1.1
1.1.1.1.1
2.2.2.2.2
2.2.2.2.2
.3.3.3.3
..3.3.3

Three groups:

group 1: repeat \$n\$ times, increment the width → encoded as \$2\$
group 2: repeat \$n-1\$ times, leave the width unchanged → encoded as \$5\$
group 3: repeat \$n-1\$ times, decrement the width → encoded as \$1\$

Final encoding: \$2+8\times5+8^2\times1=106\$

Python 3, 600 548 503 458 358 349 346 326 324 bytes
lambda n,s:p(s,q(s,(0,1,1,1.2)[n],(1,.5,3,5)[n]),n)
q=lambda s,p,q:int(p/2+(p*p/4+len(s)/q)**.5)
g=lambda s,j,i,c,n=1,l=[]:s and-~i and g(s[i:],j,i+(-1,1,0)[(2,1,n<j,(n<j*2-1)+(0<=n-j<j-1))[c]],c,n+1,l+[s[:i]])or l
p=lambda s,k,c:"\n".join([" ".join(i).center(k*(1,(2,4)[c>1])[c>0]-2)for i in g(s,(0,k)[c>1],(k,0)[c==1],c)])

Try it online!
I Know it is a bit long but i want to commit it and improve it over time...
The inputs are:
0 = Triangle
1 = square
2 = Hexagon
3 = Octagon
Thanks to:
- @caird coinheringaahing for saving 2 bytes

You can use an unnamed function as a submission here, so you can remove the f= for -2 bytes: Try it online!

@cairdcoinheringaahing Thank you for allowing this :)

05AB1E, 32 bytes
∞εLDN+DûsÂćNиì«yDи)¹è}.ΔO∍Q}£».c

Try it online!
First input is 0 for triangle, 1 for hex, 2 for oct, 3 for square. Second input is a list of characters. The program will hang forever if the list isn't of a valid length.
∞                       # infinite list [1, 2, 3...]
 ε                   }  # map each integer y to a polygon with side length y:
  L                     #  range 1..y (=> triangle)
   D                    #  duplicate
    N                   #  0-based iteration count (effectively y-1)
     +                  #  vectorized add, yielding y..(2y-1)
      D                 #  duplicate
       û                #  palindromize (=> hexagon)
        s               #  swap to get the other copy of y..(2y-1)
         Â              #  push a reversed copy: (2y-1)..y
          ć             #  head extract: 2y-1
           Nи           #  repeat that y-1 times
             ì          #  prepend that to the reversed list
              «         #  append it to the original list (=> octogon)
               y        #  push y
                Dи      #  repeat it y times (=> square)
                  )     #  wrap all polygons in a list
                   ¹è   #  index into the list using the first input
 .Δ   }                 # get the first polygon such that:
   O                    #  its sum
    ∍Q                  #  is equal to the length of the input
 £                      # cut the input in this shape
  »                     # join by newlines, joining sublists with spaces
   .c                   # center

Charcoal, 70 bytes
≔⁰ζＷφ«⎚≦⊕ζ≔∨⁼θ3ζδ≔Ｅ⮌ηκφＰ⪫Ｅδ⊟φ Ｆ§⪪”;↧↷$↑Ｒ{Ｐ≧⍘”,ＩθＦ⊖ζ«Ｍ✳Ｉκ≧⁺⁻⁶ＩκδＰ⪫Ｅδ⊟φ

Try it online! Link is to verbose version of code. Takes input as the number of sides and the characters. Explanation:
≔⁰ζ

Keep track of the size of the polygon.
Ｗφ«

Repeat until we find a size that consumes the input. (This variable is predefined to the truthy value 1000 but I'm going to redefine it.)
⎚

Clear the previous attempt from the canvas.
≦⊕ζ

Increment the polygon size.
≔∨⁼θ3ζ

Calculate the number of characters in the first row, which is 1 for the triangle and the size for the other shapes.
δ≔Ｅ⮌ηκφ

Convert the characters from a string into a list and reverse them. This allows us to iterate over them by popping from the list, which will become empty if we pop all of them.
Ｐ⪫Ｅδ⊟φ

Print the first row of the polygon.
Ｆ§⪪”;↧↷$↑Ｒ{Ｐ≧⍘”,Ｉθ

Loop over one of four strings, 5, 6, 57 or 567, depending on the number of sides. These correspond to the Charcoal directions of the left-most character in each row.
Ｆ⊖ζ«

Loop for one fewer row than the polygon size.
Ｍ✳Ｉκ

Move in the desired direction.
≧⁺⁻⁶Ｉκδ

Calculate the number of characters in this row.
Ｐ⪫Ｅδ⊟φ

Print the row.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Is it a Hamiltonian cycle on a grid?
A Hamiltonian path in a graph is a path that visits each vertex exactly once; a Hamiltonian cycle is a Hamiltonian path that is a cycle – the path forms a simple closed loop. In this challenge the graph will be a n x n grid, where n is an even number greater than 2.
Here is an example of a Hamiltonian cycle on 12x12 rectangular grid:
+---------------+   +-----------------------+
|               |   |                       |
+-----------+   |   +---+   +-----------+   |
            |   |       |   |           |   |
+-------+   |   +---+   |   +-------+   |   |
|       |   |       |   |           |   |   |
|   +---+   |   +---+   |   +-------+   +---+
|   |       |   |       |   |
|   +-------+   +---+   |   +---------------+
|                   |   |                   |
+---+   +-------+   |   |   +-----------+   |
    |   |       |   |   |   |           |   |
+---+   +---+   |   +---+   +---+   +---+   |
|           |   |               |   |       |
+---+   +---+   |   +-----------+   +---+   |
    |   |       |   |                   |   |
+---+   +---+   |   +---+   +-------+   |   |
|           |   |       |   |       |   |   |
+-------+   |   +-------+   +---+   |   |   |
        |   |                   |   |   |   |
+-------+   |   +---------------+   +---+   |
|           |   |                           |
+-----------+   +---------------------------+

The path visits each vertex exactly once and forms a simple closed loop that do not intersect or touches itself. The grid points are not shown so that the ASCII graphic is not cluttered. There are three - (---) between two horizontally connected vertices or 3 spaces if the vertices are not connected.  A single | connects two vertically adjacent vertices, spaces are used otherwise. Since the grid is not visible, the + is used only where the path takes a turn. The path will never be broken - if a segment connects two vertices, it will be --- and never - -.
Task:
You will be given an ASCII representation of a path and you need to check if it is a Hamiltonian cycle on a grid. Write a full program or a function that solves this problem.
Input:
ASCII representation of a path. It can be:
-   A mutliline string;
-   A list of strings
-   A list/array of characters
or any format that is convenient for you.
You can have an optional parameter n for the size of the grid.
You can use alternatve ASCII representation, just explain it.
Output:

A consistent value indicating that the path is a Hamiltonian cycle on a grid
A consistent value indicating that the path is not a Hamiltonian cycle on a grid. There can be several reasons for this: The path doesn’t visit all vertices; the path crosses/touches itself; there are two or more paths and not a single one. You don’t need to specify the reason – just return/print a consistent falsy value.

Test cases:
Truthy:
Optional `n` = 6

+-----------+   +---+
|           |   |   |
|   +-------+   |   |
|   |           |   |
|   +-----------+   |
|                   |
+---+   +-------+   |
    |   |       |   |
+---+   +---+   |   |
|           |   |   |
+-----------+   +---+

+-------------------+
|                   |
|   +---------------+
|   |
|   |   +-----------+
|   |   |           |
|   |   |   +---+   |
|   |   |   |   |   |
|   +---+   |   |   |
|           |   |   |
+-----------+   +---+

+---+   +-----------+
|   |   |           |
|   |   |   +-------+
|   |   |   |
|   |   |   +-------+
|   |   |           |
|   +---+   +-------+
|           |
|   +---+   +-------+
|   |   |           |
+---+   +-----------+

Optional `n` = 8

+---------------------------+
|                           |
+---+   +-----------+   +---+
    |   |           |   |
+---+   +---+   +---+   +---+
|           |   |           |
|   +---+   |   +---+   +---+
|   |   |   |       |   |
+---+   |   +---+   |   +---+
        |       |   |       |
+---+   +-------+   +---+   |
|   |                   |   |
|   +-------------------+   |
|                           |
+---------------------------+

+-------------------+   +---+
|                   |   |   |
+-------+   +---+   |   |   |
        |   |   |   |   |   |
+---+   |   |   |   +---+   |
|   |   |   |   |           |
|   |   +---+   |   +---+   |
|   |           |   |   |   |
|   +-----------+   |   |   |
|                   |   |   |
+---+   +-----------+   |   |
    |   |               |   |
+---+   +-----------+   |   |
|                   |   |   |
+-------------------+   +---+

+---+   +-------------------+
|   |   |                   |
|   |   +---+   +-----------+
|   |       |   |
|   +---+   |   +-----------+
|       |   |               |
|   +---+   +---+   +---+   |
|   |           |   |   |   |
|   +-----------+   |   |   |
|                   |   |   |
|   +-------+   +---+   |   |
|   |       |   |       |   |
|   |   +---+   +---+   |   |
|   |   |           |   |   |
+---+   +-----------+   +---+

Optional `n` = 12

+---+   +-----------+   +-------------------+
|   |   |           |   |                   |
|   |   +-------+   |   +---+   +-----------+
|   |           |   |       |   |
|   +-------+   |   +-------+   +---+   +---+
|           |   |                   |   |   |
|   +-------+   +---+   +-------+   |   |   |
|   |               |   |       |   |   |   |
|   +---------------+   |   +---+   +---+   |
|                       |   |               |
|   +-------+   +-------+   +-----------+   |
|   |       |   |                       |   |
|   |   +---+   |   +-------------------+   |
|   |   |       |   |                       |
|   |   +-------+   +-----------------------+
|   |
|   +-------------------------------+   +---+
|                                   |   |   |
+-------+   +-------+   +---+   +---+   |   |
        |   |       |   |   |   |       |   |
+-------+   +---+   |   |   |   +-------+   |
|               |   |   |   |               |
+---------------+   +---+   +---------------+

+---+   +---------------------------+   +---+
|   |   |                           |   |   |
|   |   |   +-------+   +-----------+   |   |
|   |   |   |       |   |               |   |
|   |   |   +---+   |   +-------+   +---+   |
|   |   |       |   |           |   |       |
|   |   +---+   |   |   +---+   |   |   +---+
|   |       |   |   |   |   |   |   |   |
|   +-------+   |   +---+   |   +---+   +---+
|               |           |               |
+---+   +---+   |   +---+   +-------+   +---+
    |   |   |   |   |   |           |   |
+---+   |   |   +---+   +---+   +---+   +---+
|       |   |               |   |           |
|   +---+   +---------------+   +---+   +---+
|   |                               |   |
|   +-----------+   +---+   +-------+   +---+
|               |   |   |   |               |
|   +-------+   |   |   |   |   +-------+   |
|   |       |   |   |   |   |   |       |   |
|   |   +---+   |   |   +---+   +---+   |   |
|   |   |       |   |               |   |   |
+---+   +-------+   +---------------+   +---+

+---------------------------+   +---+   +---+
|                           |   |   |   |   |
|   +---------------+   +---+   |   +---+   |
|   |               |   |       |           |
|   |   +---+   +---+   +-------+   +---+   |
|   |   |   |   |                   |   |   |
|   +---+   |   +---------------+   |   |   |
|           |                   |   |   |   |
+-------+   +---+   +-----------+   |   |   |
        |       |   |               |   |   |
+---+   |   +---+   |   +-----------+   |   |
|   |   |   |       |   |               |   |
|   +---+   |   +---+   |   +-----------+   |
|           |   |       |   |               |
|   +-------+   +---+   |   |   +-------+   |
|   |               |   |   |   |       |   |
|   |   +-----------+   |   |   |   +---+   |
|   |   |               |   |   |   |       |
|   |   |   +-------+   |   +---+   +---+   |
|   |   |   |       |   |               |   |
|   |   |   |   +---+   +-------+   +---+   |
|   |   |   |   |               |   |       |
+---+   +---+   +---------------+   +-------+

Falsy:
Optional `n` = 6

; Two paths
+-------------------+
|                   |
|   +-----------+   |
|   |           |   |
|   +-----------+   |
|                   |
+-------+   +-------+
        |   |
+-------+   +-------+
|                   |
+-------------------+

; Two paths
+-------+   +-------+
|       |   |       |
|   +---+   +-------+
|   |
|   +---------------+
|                   |
|   +-----------+   |
|   |           |   |
|   +---+   +---+   |
|       |   |       |
+-------+   +-------+

; The path doesn't visit each vertex
+-----------+   +---+
|           |   |   |
|           |   |   |
|           |   |   |
+-------+   +---+   |
        |           |
+---+   +---+   +---+
|   |       |   |
|   +-------+   +---+
|                   |
+-------------------+

; The path doesn't visit each vertex and touches itself
; (so visits some points more than once)
+-------------------+
|                   |
|   +-----------+   |
|   |           |   |
|   |   +-------+   |
|   |   |           |
|   |   +-------+   |
|   |           |   |
+---+-----------+   |
    |               |
    +---------------+

; The path doesn't form a loop and touches itself
+---+   +---+   +---+
|   |   |   |   |   |
|   |   |   |   |   |
|   |   |   |   |   |
|   |   |   |   |   |
|   |   |   |   |   |
|   |   |   |   |   |
|   |   |   |   |   |
|   |   |   |   |   |
|   |   |   |   |   |
+---+---+   +---+---+

Optional `n` = 8

; Two paths
+-------------------+   +---+
|                   |   |   |
|   +-----------+   |   |   |
|   |           |   |   |   |
|   +-------+   |   +---+   |
|           |   |           |
+-------+   |   +-----------+
        |   |
+---+   +---+   +-----------+
|   |           |           |
|   |   +---+   |   +-------+
|   |   |   |   |   |
|   +---+   +---+   +-------+
|                           |
+---------------------------+

; The path doesn't visit each vertex
+---------------+   +-------+
|               |   |       |
|   +-------+   +---+       |
|   |       |               |
|   |   +---+   +---+       |
|   |   |       |   |       |
|   |   +-------+   +-------+
|   |
|   |   +-------------------+
|   |   |                   |
|   +---+   +---+   +---+   |
|           |   |   |   |   |
|   +---+   |   |   |   |   |
|   |   |   |   |   |   |   |
+---+   +---+   +---+   +---+

; The path doesn't visit each vertex
+---------------+   +-------+
|               |   |       |
|   +-----------+   +---+   |
|   |                   |   |
|   +---+   +-----------+   |
|       |   |               |
+---+   |   +-------+   +---+
    |   |           |   |
+---+   +-------+   |   |
|               |   |   |
|   +-----------+   |   |
|   |               |   |
|   +---------------+   +---+
|                           |
+---------------------------+

; Two paths
+-----------+   +-----------+
|           |   |           |
|   +---+   |   |   +-------+
|   |   |   |   |   |
|   |   |   |   |   +-------+
|   |   |   |   |           |
+---+   |   |   +-------+   |
        |   |           |   |
+---+   |   +-----------+   |
|   |   |                   |
|   |   |   +-----------+   |
|   |   |   |           |   |
|   +---+   +-----------+   |
|                           |
+---------------------------+

; The path touches itself (so visits some points more than once)
+---+   +-------------------+
|   |   |                   |
|   |   |   +---+   +-------+
|   |   |   |   |   |
|   +---+   |   |   |   +---+
|           |   |   |   |   |
+---+   +---+   |   |   |   |
    |   |       |   |   |   |
+---+   +-------+---+---+   |
|               |   |       |
+-------+   +---+   +---+   |
        |   |           |   |
+-------+   +-----------+   |
|                           |
+---------------------------+

; The path doesn't form a loop
+---------------+   +-------+
|               |           |
+-------+   +   +-------+   |
        |   |           |   |
+-------+   +-----------+   |
|                           |
|   +-------------------+   |
|   |                   |   |
|   +---+   +-----------+   |
|       |   |               |
|   +---+   +-----------+   |
|   |                   |   |
|   +---------------+   |   |
|                   |   |   |
+-------------------+   +---+

Wining criteria:
The shortest solution in bytes in each language wins.
I'll highly appreciate if you add explanation of the code and the algorithm you used.

Do we have to use the ASCII representation given? Or can we use an alternative ASCII representation?

Are we allowed to take inputs drawn with only a single - (rather than ---) as the horizontal connector?

@Nick Kennedy Yes, you can.

@Jonah Yes, you can.

Charcoal, 63 55 46 bytes
ＡＭ↗ Ｗ⁼№ＫＶ#¹«✳⊗⁻¹⌕ＫＶ#¦ ¿¬∨﹪ⅈ⁴﹪ⅉ²⊞υω»¿‹ＬυＸＮ²⎚«⎚¹

Try it online! Link is to verbose version of code. Edit: Saved 8 bytes by using a more cumbersome but still acceptable input format. Saved 9 bytes by requiring the path only uses #s. Explanation:
Ａ

Copy the path to the canvas.
Ｍ↗

Print a space one square in from the bottom-left corner (the print command left the cursor one square below the bottom-left corner). This should break the loop of #s into a line.
Ｗ⁼№ＫＶ#¹«

Try to follow the line to its end, following the path of #s that used to have two neighbours.
✳⊗⁻¹⌕ＫＶ#¦

Overwrite the line as we go.
¿¬∨﹪ⅈ⁴﹪ⅉ²⊞υω»

Keep track of how many vertices we meet along the way.
 ¿‹ＬυＸＮ²⎚

Check whether we managed to visit every vertex. If not, then just clear the canvas.
«⎚¹

If we visited every vertex then output 1 as a truthy value (which actually prints as -).

You can use alternatve ASCII representation.

@GalenIvanov Would this be acceptable?

Yes, it is acceptable.

@GalenIvanov How about this?

Yes, it's fine. You can even have only one # horizontally instead of ###

@GalenIvanov Thanks, but I think it would be possible to fool the algorithm in that case.

Jelly, 34 bytes
Ø1©ȧn⁶µŒṪạ®SỊƊƇḢ©Wḟ@ƲƬṖṪ<3Ȧȧm2m€4Ȧ

A monadic Link accepting a list of lists of characters (the lines) which yields 1 for a Hamiltonian or 0 otherwise. Uses the layout in the question (any non-space chars as path parts will work).
Try it online! Or see the test-suite.
How?
Starts at the top-left, [1,1], and finds a neighbouring non-space until no neighbours can be found, then checks if the final position is the neighbour below the top-left, [2,1], (to confirm the path was a loop) and that no other non-spaces remain (to confirm there were not multiple paths). If so a final check is made that all the vertices were non-spaces too.
Ø1©ȧn⁶µŒṪạ®SỊƊƇḢ©Wḟ@ƲƬṖṪ<3Ȧȧm2m€4Ȧ - Link: list of lines, M
Ø1                                 - literal [1,1]
  ©                                - (copy this to the register and yield it)
   ȧ                               - logical AND (with M) -> M
     ⁶                             - literal space character
    n                              - not equal? (vectorises)
      µ                            - new monadic chain, call that N
       ŒṪ                          - truthy multidimensional indices
                     Ƭ             - collect up while distinct, applying:
                    Ʋ              -   last four links as a monad:
              Ƈ                    -     filter keep if (find neighbours):
             Ɗ                     -       last three links as a monad:
         ạ                         -         absolute difference (vectorises):
          ®                        -           current register value
           S                       -         sum
            Ị                      -         insignificant? (abs(z)<=1)
               Ḣ                   -     head (a neighbour [x,y] or 0 if none)
                ©                  -     (copy this to the register and yield it)
                 W                 -     wrap in a list
                   @               -     with swapped arguments:
                  ḟ                -       filter discard
                      Ṗ            - remove rightmost
                       Ṫ           - get rightmost (or 0 if none)
                        <3         - less than three? (vectorises)
                          Ȧ        - all non-zero when flattened?
                           ȧ       - logical AND (with N) ->
                                   - (i.e. N if the entire path looped from [1,1]
                                   -  back to [2,1] leaving nothing unconsumed
                                   -  else 0)
                            m2     - every 2nd value
                              m€4  - every 4th value of each
                                 Ȧ - all non-zero when flattened?

JavaScript (ES7),  126 124  122 bytes
Takes input as (n)(matrix). Returns a Boolean value.
n=>g=(m,X=k=0,Y=0,d=0)=>m.map((r,y)=>r.map((c,x)=>++c|(x-X)**2+(y-Y)**2-1||g(m,x,r[++d,x%4|y%2||k++,x]=y)))|d>1?k=g:k==n*n

Try it online!
How?
Starting at \$(0,0)\$, we flood-fill the path and increment a counter \$k\$ each time we go through a cell \$(x,y)\$ such that \$x\equiv 0\pmod 4\$ and \$y\equiv 0\pmod 2\$.
At the end of the process, we must have \$k=n^2\$.
We additionally make sure that no cell has more than 2 neighbors. If it does happen, we set \$k\$ to a non-numeric value to force the final test to fail.

You can use alternatve ASCII representation.

@GalenIvanov Thanks for the notification. That would not help much in my case, because I'm just testing space vs not-space.

Can we take the input as a matrix of zeros and ones?

Jelly, 54 bytes
n⁶,Z$µØ0jm2N,¹ƇɗƝ)m2)Z×LƊ€2¦Ẏ€;"/µØ-ḟN}Ḣɗ,+¥ƭƒịṪ¥¥ƬL=L

Try it online!
A monadic link which takes a list of strings as input and returns a boolean. The strings use the format of the question but omitting every other character (so half the width). Full explanation to follow.

J, 125 bytes
p=.((,-)#:1 2)|.!.0]
f=.([:(''-:2 0~.@-.~[:,]*+/@p)' '~:])*1-1 e.[:([:,@(,]+1=(2|#\)*/4|#\@|:)([:>./]*"2 p)^:_)_(<0 0)}' '~:]

Try it online!
Just a first draft, but all test cases are passing.  Will attempt to golf and add explanation this week.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Time to settle this: Java vs C++
Story
In an unnamed company, some people use Java and some use C++. This was always a nuisance, and they kept on arguing which single language they should all be using. To settle the dispute, the management decided that they'll buy a translator program that will be able to rewrite their C++ programs to Java and vice versa. An important part of the translator will be a routine that will rewrite all the identifiers. This is because Java coders in the company write multiword identifiers in a different way than C++ coders in the company do. We will now describe both methods. In Java a multiword identifier is constructed in the following manner: the first word is written starting with a lowercase letter, and the following ones are written starting with an uppercase letter, no separators are used. All other letters are lowercase. Examples of Java identifiers are javaIdentifier, longAndMnemonicIdentifier, name and kSP.In C++ people use only lowercase letters in their identifiers. To separate words they use the underscore character '_'. Examples of C++ identifiers are cpp_identifier, long_and_mnemonic_identifier, name (here Java and C++ people agree), and k_s_p.
Task
Write the identifier translation routine/function/etc. Given an identifier, detect whether it is a Java identifier or C++ identifier (as defined below) and translate it to the other dialect. Translation must preserve the order of words and must only change the case of letters and/or add/remove underscores. You may assume all input to be valid, as checking was done for you in the superroutine.
More formally
A Java identifier only contains characters from [a-zA-Z] and starts with a lowercase letter. Every uppercase character is a word boundary.
A C++ identifier only contains characters from [a-z_] and additionally doesn't start or end with an underscore nor does it contain two adjacent underscores anywhere within. Every underscore is a word boundary.
Translation: switch every word boundary, that is, if it was an underscore, remove it and capitalize the following letter, if it was uppercase, prepend an underscore and lowercase the letter.
Input
The input consists of one line that contains an identifier. It consists of letters of the English alphabet and underscores. Other standard input styles are also valid.
Output
If the input identifier is a Java identifier, output/return its C++ version. If it is a C++ identifier, output/return its Java version. You may assume it will be at least one of those (both is possible).
Examples
long_boring_identifier  |  longBoringIdentifier
otherWay                |  other_way
same                    |  same
getHTTP                 |  get_h_t_t_p
invalid_Input           |  <undefined>

All the standard rules apply, none of the standard loopholes are allowed.

Closely related.

Well, this also requires solving in the other way.

Even more closely related - given that the only difference is whether the first letter is lowercase or uppercase, I'd consider this a dupe.

@Mego Dang it, the people over in the Sandbox haven't found any dupes. And it's been there for quite a while as well. Partly due to me putting of making it live. Good catch!

@FryAmTheEggman In fact you mentioned that same one on meta. For sake of completeness you also mentioned the reverse Also related, though no-one found a total dupe. Good catch on Mega's part, too bad no-one in the sandbox got it.

Somehow I had already forgotten, thanks for pointing out the other one! And sorry I didn't catch the dupe beforehand, you did basically everything right.

QuadR, 19 bytes
_(.)
[A-Z]
\u1
_\l&

Try it online!

Node.js, 61 bytes
Contains the unprintable character \x7F.
s=>s.replace(/_.|[A-Z]/g,s=>Buffer(s[1]||''+s).map(x=>x^32))

Try it online!

JavaScript (ES6), 72 bytes
s=>s.replace(/_.|[A-Z]/g,s=>s[1]?s[1].toUpperCase():'_'+s.toLowerCase())

Try it online!

Retina, 40 34 bytes
([A-Z])
_$1
T`Ll`lL`_.
_([A-Z])
$1

Try it online!
Explanation
([A-Z])            # Replace all uppercase letters with
_$1                # an underscore followed by that same letter.
T`Ll`lL`_.         # Replace lowercase letters with uppercase letters and vice versa when after an underscore
_([A-Z])           # Replace an underscore followed by an uppercase letter
$1                 # with just that letter

Python 3.8, 95 bytes
First golf in a while. Comments welcome.
lambda s:"".join(["_"*(x!=(l:=x.lower()))+l,x.upper()][p=="_"]*(x!="_")for p,x in zip("."+s,s))

Zsh -oextendedglob, 82 69 51 bytes
<<<${1//(#m)(_?|[A-Z])/${${MATCH[2]:u}:-_$MATCH:l}}

Try it online!
Try it online!

Try it online!
Even if the flags count toward byte count, adding 14 bytes for -oextendedglob still undercuts the 82 byte program!
<<<${1//(#m)(_?|[A-Z])/${${MATCH[2]:u}:-_$MATCH:l}}
   ${1//              /                           }  # replacement
        (#m)                                         # enable $MATCH parameter
            (_?|[A_Z])                               # "?" matches any character
                         ${MATCH[2]:u}               # substitute 2nd char, uppercased
                       ${             :-_$MATCH:l}   # if empty, substitute "_" and lowercased match
<<<                                                  # print to stdout


text:
Is it a circumfix?
Introduction
We all know prefixes and suffixes. But there are other types of affixes that exist too. Such as circumfixes, a type of affix that has two parts, one of which is a prefix and another of which is a suffix. Figuring out whether some string is a prefix or a suffix of some other string is easy, but what about figuring out whether it might be a circumfix?
That is today's challenge - create a program or function which takes two strings as input, and determine whether the first is a circumfix of the second.
For the purposes of this challenge a string i1 is a circumfix of another string i2 if and only if there exists some non-empty string j which is a contiguous substring of i2 such that removing j from i2 results in i1, and j is neither a prefix nor a suffix of i2 (if it is, you don't have a circumfix, you just have a suffix or a prefix respectively).
For example, "fog" is a circumfix of "frog", because removing "r" from "frog" produces "fog".
When given valid input, your program either needs to output a single consistent value of your choice if the first input string is a circumfix of the second, and any other value if it is not, or vice versa. For example, you may decide have your program output 6 when the first string is a circumfix of the second, in which case any output except 6 is acceptable when it is not.
This is code-golf, so do make sure to golf your code.
Test cases
Format:
"String 1", "String 2" -> output
    comments about the test case - in all these test cases, the output will be true if string 1 is a circumfix or string 2 and false otherwise
"apply", "appreciably" -> true
    "app]reciab[ly"
"rake", "racket by the lake" -> true
    multiple options - "r]acket by the l[ake" and "ra]cket by the la[ke"
"trout", "trumpet" -> false
    Doesn't work at all
"bring", "brought him a gong" -> false
    You only get to remove one substring - "br]ought h[i]m a go[ng" is not allowed
"falcon", "false conundrum" -> false
    You can't have extra stuff at the start or end either - "fal]se [con(undrum)" is not allowed
"goose", "goosebumps" -> false
    "goose]bumps[" is just a prefix
"lame", "blame" -> false
    And "]b[lame" is just a suffix
"pale", "pale ale" -> true
    "pale] ale[" is just a prefix, but "pal]e al[e" is a circumfix, so this is allowed
"b", "barb" -> false
    This could be a prefix ("b]arb[") or a suffix ("]bar[b"), but not a circumfix - "b]ar[b" is not allowed
"abba", "aba" -> false
    "abba" can be split into a prefix of "aba" ("ab") and a suffix of "aba" ("ba"), but "abba" is still not a circumfix of "aba"
"friend", "friend" -> false
    It's only a proper circumfix if you actually remove something - "fri][end" doesn't make the cut
"float", "on" -> false
    You may not assume the first input will be shorter than the second one
"", "" -> false
    One or both input strings may be empty
"Twin Sister", "Twister" -> false
    Inputs are ordered - you may reverse the order, but there must be a consistent ordering
"case", "Castle" -> false
    Inputs are case sensitive
"<<@ 23|>", "<<@23??|> 23|>" -> true
    "<<@]23??|>[ 23|>", not all characters will be letters)

Are empty inputs possible?

@LuisMendo Yes, one or both inputs may be empty

J, 23 21 20 bytes
>&#*]e.1}:@}.-&#]\.[

Try it online!
-1 byte thanks to Bubbler
Return true if:

>&# left arg is strictly longer than right (see the "friend"/"friend" test case)
* and...
] the right arg
e. is an element of the list formed by...
1 }:@}. removing the first and last elements of...
-&# ]\. [ all the outfixes \. of the left arg [ whose size is the difference in size between the two args -&#

That is, J has a builtin to subtract the "chunks" in the middle of the necessary size and leave us with the remaining prefixes and suffixes, catted.  We simply have to remove the non-proper ones (ie, the first and last elements of the list of outfixes), and check for what we're searching for.

+1 for the perfect use case of outfix.

1}:@}. in place of [:}:@}. saves a byte. Try it online!

@Bubbler thanks and nice catch.  updated.

Python3, 86 84 83 80 77 76 bytes
lambda a,b:len(a)<len(b)*any(a==b[:i]+b[i-len(a):]for i in range(1,len(a)))

Try it online!
-2 bytes thanks to @Value Ink whitespace before and after ==
-1 byte remove whitespace.
-3 bytes thanks to @ovs using any to write for loop in one line.
-3 bytes by replacing and with *
-1 byte by replacing def with lambda
Python3.8, 71 bytes
lambda a,b:(c:=len(a))<len(b)*any(a==b[:i]+b[i-c:]for i in range(1,c))

Try it online!

Welcome to CGCC! Since the goal is to have a smaller byte count, you will want to remove the whitespace in your a == b... check.

I put your 3.8 code into a shell and got a SyntaxError.

@AlexHall fixed it.

Retina 0.8.2, 17 bytes
^(.+)(.+)¶\1.+\2$

Try it online! Link includes test suite that takes each test on its own line with the test values separated by a tab and converts them into individual tests with the values on separate lines as the main program expects.

Brachylog, 13 12 bytes
~c₃{b&}ᵐ↺b↺c

Try it online!
Takes string 1 (the possible circumfix) through the output variable, string 2 through the input variable, and outputs through success or failure.
I recall that at some point my original solution could be 12 bytes, but as of now subscriptless c seems to cycle through all partitions infinitely, causing false test cases to not terminate except it would also cause false positives where the two inputs are equal.
(I tried golfing {b&}ᵐ to Xz∧X (when it's already a shorter alternative to {l>0&}ᵐ), but it has a false positive for the empty test case, since there's no problem cycling an empty list to the length of the longest when everything is empty.)
~c₃             Split the input variable into three parts, such that
   {  }ᵐ        each of them
    b&          can have its first element removed (i.e. it is not empty).
        ↺       Rotate the list of partitions left,
         b      remove the first element (which was in the middle),
          ↺     and rotate the remaining partitions again.
           c    Do they concatenate to the output variable?

Jelly, 11 bytes
⁻ȧŒṖḢ;ṪƊ€iɗ

Try it online!
Takes string 1 (the potential circumfix) as the right/second argument, string 2 as the left/first argument, and outputs 0 if it's not a circumfix and a positive integer otherwise.
(The test footer is bad, but it's better than nothing.)
⁻              The arguments are not equal,
 ȧ             and
          ɗ    you also get a truthy value from the next three links:
         i     the index of the right argument (defaulting to 0) in
  ŒṖ           the list of all partitions of the left argument
        €      with each partition mapped to
    Ḣ;ṪƊ       the concatenation of its first and last elements.

Although this is mostly just a translation of my Brachylog answer, ŒṖ cannot generate empty elements of partitions while c is obligated to, so prefixes and suffixes are naturally accounted for.
This 15-byte monstrosity is what I had before I just tried putting the ⁻ at the start of the program... and before I realized I could use Ḣ;Ṫ: ŒṖ1,0ịFƊ€⁸ṭṚi>1

Regex (POSIX ERE or better), 17 bytes
Takes the two strings in joined format, delimited by a single newline.
^(.+)(.+)
\1.+\2$

Turned out to be identical to Neil's Retina answer, so I'm mainly answering this to demonstrate it in a wide range of regex engines:
Try it online! - ECMAScript (SpiderMonkey)
Try it online! - ECMAScript 2018 (Node.js)
Try it online! - Perl 5
Try it online! - PCRE2 (PHP)
Try it online! - .NET (C#)
Try it online! - Java (JDK)
Try it online! - Python
Try it online! - Ruby
Try it online! - POSIX ERE (sed), tab as delimiter
Try it online! - POSIX ERE (egrep), tab as delimiter

¶ is how Retina encodes a newline in a program that is read from a single file of newline-separated parts; you can use -m to indicate that newlines should be literal in which case you have to provide each part as a separate file or -e argument.

@Neil Yeah, I had only taken a very quick look at your program after writing mine. A cursory read of its description made it look like the delimiter was tab, but it was just that your test suite converted tab to newline.

Zsh, 60 bytes
for ((c=#2;++i<$#1;))t=${1: i}&&2=${2:/${1%$t}?*$t}
((c-#2))

Try it online!
Key constructs here:

${var:/pattern} will replace $var by the empty string if pattern matches the full string.
((#var)) is zero if $var is empty.

Ruby, 76 62 bytes
->a,b{s=a.size;s<b.size&&(1..s-2).any?{|i|a==b[0,i]+b[i-s,s]}}

Try it online!

Bracmat, 54 bytes
(C=c w a z.!arg:(?c.?w)&@(!c:%?a (%?z&@(!w:!a % !z))))

This solution uses associative (string) pattern matching and expression evaluation during pattern matching.
The associative pattern is %?a %?z, which splits the subject, !c, in two strings, neither of which is empty. (The % prefix ensures that a pattern variable does not accept a neutral element, i.e. an empty string, in the case of string pattern matching.)
The expression that is evaluated during pattern matching is @(!w:!a % !z). This happens to be another associative string pattern matching operation.
Try it online!

05AB1E, 9 8 bytes
.œÅΔćìθQ

Try it online!
Outputs a non-negative number if it is a circumfix, -1 otherwise.

Icon, 70 bytes
procedure f(a,b)
return(1<*a<*b&a==b[1:i:=2to*a]||b[i-1-*a:0]&1)|0
end

Try it online!

Ruby, 40 39 bytes
->a,b{a+b=~/^(.+)(.+)(?=#{b}$)\1.+\2$/}

Try it online!
How
Simple regex: if a+b can be split in 5 parts ABCDE where A==C and B==E, and b=CDE, then a is a circumfix of b.
Thanks benrg for pointing out a problem with the first solution (and saving 1 byte).

I really like this.

This fails on inputs like "aa","aabaa" because it finds an incorrect solution and rejects it without backtracking to look for another one. I don't know Ruby, but could you do something like /^(.+)(.+)(?=\Q$b\E$)\1.+\2$/? Then you wouldn't need the final test.

Haskell, 72 71 62 bytes
\a b->or[a==take i b++drop j b|j<-[2..length b-1],i<-[1..j-1]]

Try it online!

-1 byte by moving l a<l b into the list comprehension, where it only needs a , rather than an &&
-9 bytes from benrg's suggestion

\a b->or[a==take i b++drop j b|j<-[2..length b-1],i<-[1..j-1]] saves 9 bytes.

@benrg applied, thanks!

Python 3, 69 bytes
f=lambda c,s,i=1:i<len(c)<len(s)and(c==s[:i]+s[i-len(c):])|f(c,s,i+1)

Try it online!
-2 bytes thanks to Bubbler

Curry, 28 bytes
Tested to work in both PAKCS and KiCS2
f(a:b++c:d)(a:b++_:_++c:d)=1

Try it online!
This returns 1 if the first argument is a circumfix and nothing otherwise.  In cases where there are multiple ways the string could be a circumfix it will return 1 multiple times i.e. it is non-deterministic but always gives 1.  I think this is fine.
The program is basically just a pattern match checking that the first input is made up of two non-empty strings and that the second is made of the same two strings with another non-empty string between them.
This uses two pattern matching features available to Curry not present in Haskell.  The first is ++ patterns, and the second is pattern variables.  e.g. we require the two as to be the same a.
This allows it to beat out the Haskell answer handily.
Testing
TIO has a limited ability to test things like this.  Paste the following to smap and run in PAKCS 2.2.0 for better testing abilities:
import Control.SetFunctions

f(a:b++c:d)(a:b++_:_++c:d)=1

-- Helper to run tests
helper :: [a] -> [a] -> Bool
helper x y =
  not $ isEmpty $ set0 $ f x y

main =
  [ helper "fog" "frog"
  , helper "apply" "appreciably"
  , helper "rake" "racket by the lake"
  , helper "trout" "trumpet"
  , helper "bring" "brought him a gong"
  , helper "falcon" "false conundrum"
  , helper "goose" "goosebumps"
  ]

This test handler will not work in KiCS2 or at least not on the version used by smap.  But the function itself does if you want to manually test it.

Wolfram Language (Mathematica), 30 bytes
#2/.{p__,__,s__}/;{p,s}==#->0&

Try it online!
Takes two lists of characters as input. Returns 0 if the first string is a circumfix of the second, or the second string otherwise.

JavaScript (ES6), 70 bytes
Takes input as (a)(b).
a=>b=>[...a].some((_,i)=>b[l=a.length]&&a==b.slice(0,l-i)+b.slice(-i))

Try it online!

Eventually you can avoid returning undefined moving the first test inside some

@edc65 Good idea. Updated.

JavaScript (ES6), 72 bytes
s=>t=>[...s].some((x,i)=>t[l=s.length]&&i&&s==t.slice(0,i)+t.slice(i-l))

Return true if

the second string is longer than the first
there is a position to split the first string in 2 parts, such as the second string starts with the left part and ends with the right part

Test

z=`"apply", "appreciably" -> true
    "app]reciab[ly"
"rake", "racket by the lake" -> true
    multiple options - "r]acket by the l[ake" and "ra]cket by the la[ke"
"trout", "trumpet" -> false
    Doesn't work at all
"bring", "brought him a gong" -> false
    You only get to remove one substring - "br]ought h[i]m a go[ng" is not allowed
"falcon", "false conundrum" -> false
    You can't have extra stuff at the start or end either - "fal]se [con(undrum)" is not allowed
"goose", "goosebumps" -> false
    "goose]bumps[" is just a prefix
"lame", "blame" -> false
    And "]b[lame" is just a suffix
"pale", "pale ale" -> true
    "pale] ale[" is just a prefix, but "pal]e al[e" is a circumfix, so this is allowed
"b", "barb" -> false
    This could be a prefix ("b]arb[") or a suffix ("]bar[b"), but not a circumfix - "b]ar[b" is not allowed
"abba", "aba" -> false
    "abba" can be split into a prefix of "aba" ("ab") and a suffix of "aba" ("ba"), but "abba" is still not a circumfix of "aba"
"friend", "friend" -> false
    It's only a proper circumfix if you actually remove something - "fri][end" doesn't make the cut
"float", "on" -> false
    You may not assume the first input will be shorter than the second one
"", "" -> false
    One or both input strings may be empty
"Twin Sister", "Twister" -> false
    Inputs are ordered - you may reverse the order, but there must be a consistent ordering
"case", "Castle" -> false
    Inputs are case sensitive
"<<@ 23|>", "<<@23??|> 23|>" -> true
    "<<@]23??|>[ 23|>", not all characters will be letters)`

f=s=>t=>[...s].some((x,i)=>t[l=s.length]&&i&&s==t.slice(0,i)+t.slice(i-l))

z.split('\n').forEach((s,i)=>{
    var m = s.match(/"([^"]*)", "([^"]*)" -> (true|false)/)
    if (m) {
        console.log(`"${m[1]}" "${m[2]}" should be ${m[3]} and is ${f(m[1])(m[2])}`)
    }
})

Prolog (SWI), 104 bytes
e([],_).
e([H|T],[H|U]):-e(T,U).
e(L,[_|U]):-e(L,U).
f(X,Y):-string_chars(X,A),string_chars(Y,B),e(A,B).

Try it online!

-21 bytes

Java (JDK), 46 bytes
a->b->(a+"\0"+b).matches("(.+)(.+)\0\\1.+\\2")

Try it online!
Credits

-2 bytes thanks to ceilingcat
-2 bytes thanks to Sara J
The 46 bytes solution (-86 bytes) is actually the full implementation in Java of deadcode's regex answer (which incidentally also contains a Java solution, but only to demonstrate the regex).

You could save 2 bytes by doing return r instead of return r>0 at the end.

@SaraJ Indeed, I thought it was true/false because of the examples in the challenge. The output format is nice for once ;-)

Oh wow, I didn't realize/remember you could do a regex match in Java without a lot of boilerplate. I suppose I'll keep the boilerplated version in my TIO testbed though, since otherwise it has to compile the regex each time it's called, right?

@Deadcode Yes, Java is boilerplate, but sometimes not as boilerplate as one might thing :-) The JVM keeps a cache of the last 8 regex (number to verify) that it compiled so no need to worry (too much) about performances, therefore you may shrink your version safely.

I remember now why I didn't use it. It matches the whole string, which would conflict with my format for pure regexes (which have anchors). It's great for golfing Java functions/programs that use regexes, though! Like this.

APL (Dyalog Unicode), 21 bytesSBCS
Anonymous infix function. Takes strings 1 and 2 as left and right arguments. Requires ⎕IO←0.
{(⊂⍺)∊∊¨↑∘⍵¨¨(1↓⍳≢⍺)-⊂0,~/≢¨⍺⍵}

Try it online!
{…} "dfn"; ⍺ and ⍵ are is strings 1 and 2:
 ⍺⍵ strings 1 and 2
 ≢¨ length of each
 ~/ remove elements from the first that are in the second (gives empty list if same length)
 0, prepend zero
 ⊂ enclose to treat as a whole
 (…)- subtract that from the following:
  ≢⍺ length of string 1
  ⍳ indices zero through that
  1↓ drop the first one (the zero)
This gives us the head-tail pairs to try.
 ¨¨ for element of each of the head-tail pairs:
  ↑∘⍵ take that many characters from string 2 (from the end if negative)
 ∊¨ ϵnlist (flatten) each
 (…)∊ is the following an ϵlement of that?
  ⊂⍺ the entire string 1

This appears to have a false positive for "abba", "aba"

Perl 5, 73 77 bytes
sub f{(grep$_[1]=~/^@{[$_[0]=~s|.{$_}|\Q$&\E.+|r]}$/,1..length($_[0])-1)?1:0}

Try it online!

Fails on "....", "any string". Try it online!

This should be one of the tests. Corrected for this now, 4 more bytes.

Nekomata + -e, 7 bytes
≠;sᵃN,=

Attempt This Online!
≠;sᵃN,=
≠           Check that the two inputs are not equal
 ;          Split the second input into two parts
  s         Take a suffix of the second part
   ᵃN       Check that both the first part and the suffix are non-empty
     ,      Join the first part and the suffix
      =     Check that the result is equal to the first input