g | x | w | all
Bytes Lang Time Link
026Arturo250919T000002Zchunes
013Dyalog APL250918T221537ZAaron
00305AB1E250918T090435ZKevin Cr
002Japt f250918T082113ZShaggy
120Pascal250918T060016ZKai Burg
005W200123T013915Zuser8505
049Racket160501T052411ZWinny
032JavaScript ES6160214T190459ZNeil
029Mathematica160215T020038ZLegionMa
028R160215T003302Zmnel
045𝔼𝕊𝕄𝕚𝕟160215T001515ZMama Fun
005sh160215T000233ZRainer P
013vim160214T193201ZDoorknob
005Pyth160214T190018ZMaltysen
027Bash160214T193916ZDoorknob
036Python 2160214T191804ZAndreas
004TeaScript160214T190250ZDowngoat
047Python 2160214T191758ZBlue

Arturo, 26 bytes

$[a b][select a=>[in? b&]]

Try it!

Dyalog APL, 13 bytes

Accepts the list to search through on the left and what to search for on the right.

⊣(/⍨)∨/⍤⍷¨⍨∘⊂­⁡​‎‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏⁠‎⁡⁠⁣⁣‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢‏⁠‎⁡⁠⁣‏⁠‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁡‏‏​⁡⁠⁡‌­
        ⍷¨⍨    # ‎⁡Find-each backwards (search for the right arg within the left)
           ∘⊂  # ‎⁢after enclosing the right so that it is distributed to each of the left
     ∨/        # ‎⁣Followed by or-over so that any occurrence marks that word as having the search phrase
 (/⍨)          # ‎⁤Compress backwards
⊣              # ‎⁢⁡over the left arg
💎

Created with the help of Luminespire.

05AB1E, 3 bytes

ʒIå

Inputs in the order \$list, searchInput\$.

Try it online or verify all test cases.

An equal-bytes alternative would be:

δåÏ

Inputs in the order \$searchInput, list\$.

Try it online or verify all test cases.

Explanation:

ʒ    # Filter the first (implicit) input-list by:
 Iå  #  It contains the second input-string as substring
     # (after which the filtered list is output implicitly as result)

δ    # Using the first (implicit) input-string as argument, map each value in the
     # second (implicit) input-string to:
 å   #  Contains-check, using the argument on the current value
     # (resulting in a list of 1s and 0s whether it contained the substring)
  Ï  # Keep the values in the second (implicit) input-string at the truthy positions
     # (after which the filtered list is output implicitly as result)

Japt -f, 2 bytes

øV

Try it here

Pascal, 120 B

This program requires a processor supporting features of Extended Pascal as described in ISO standard 10206, in particular the string schema support and the index function. The search pattern is entered on the first line and subsequent lines are list members. The golfed program assumes a non‐empty list and uses a repeat … until loop because of that. The input strings are capped to 99 characters.

program p(input,output);var p,s:string(99);begin
readLn(p);repeat readLn(s);if 0<index(s,p)then writeLn(s)until EOF end.

Sane version:

{ The special `program` parameters `input` and `output` are `text` files.
  `Text` files are (possibly empty) sequences of (possibly empty) lines.
  This is guaranteed by the processor: A missing end‐of‐line character
  sequence at the end of a file is automatically inserted. }
program makeASearchEngine(input, output);
    var
        needle, line: string(maxInt);
    begin
        { Attempting to read past the end of a file causes an error. }
        if not EOF(input) then
        begin
            readLn(input, needle);
            
            while not EOF(input) do
            begin
                readLn(input, line);
                { `index(source, pattern)` finds the first occurrence of
                  `pattern` in `source` and returns the starting index.
                  In Pascal `string` indices are 1‐based, so 0 is invalid. }
                if index(line, needle) > 0 then
                begin
                    writeLn(output, line)
                end
            { Note that in Pascal the semicolon serves as a separator.
              It can be omitted if you do not want to separate anything. }
            end
        end
    end.

The program works correctly for ε (empty word, i. e. a zero‐length string). ε is present everywhere so all list members are printed.

W, 5 bytes

b@t!W

Explanation

ba      % Implicit inputs
  b     % Access the second operand
   @    % Show two operands (yields [b,b,a])
      W % Select everything in a that fullfills this condition:
    t   % Trim everything in the current item
        % that appears in the input
        % Yields ([b,b.trim(a)])
     !  % Negate this result, determining whether
        % the input is a subset of the current item

        % Keeping all of the items that fullfill
        % this condition yields a list by default
```

Racket, 49 bytes

(λ(l s)(filter-map(curryr string-contains? s)l))

JavaScript ES6, 32 bytes

(s,a)=>a.filter(e=>~e.search(s))

33 bytes if the string might contain regexp metacharacters:

(s,a)=>a.filter(e=>~e.indexOf(s))

Mathematica, 29 bytes

Select[#2,StringContainsQ@#]&

Very simple.

R, 38 28 bytes

function(x,y)grep(y,x,,,T,T)

simply a wrapper for grep, with value = TRUE to return the value [not a logical flag], and fixed (to allow regex-like strings to be searched and not processed as regex.

edit - 10 bytes by passing empty arguments to allow positional matching

𝔼𝕊𝕄𝕚𝕟, 4 chars / 5 bytes

í⒡ăî

Try it here (Firefox only).

Simple.

Explanation

Filter input array by string input.

sh, 5 bytes

Accepts a list of words on stdin, one per line, and a search string as command line argument.

fgrep

This submisson should be valid by the rules on scoring builtin functions.

vim, 13

dd:v/\V<C-r>"<BS>/d<cr>

Expects input as

th
thing
awesome
potato
example

Outputs on separate lines.

dd      delete first line into " (default) register
:v/     apply to every line that doesn't match the following regexp...
\V        "very nomagic" - strips chars of their special regex meaning
<C-r>"    paste contents of " register into the command
<BS>      remove the trailing newline from the first line
/d      ... delete the lines

Pyth - 5 bytes

f}zTQ

Try it online here.

Filters the input list by if the input string is in it.

Bash, 27 bytes

tr \  \\n<<<${@:2}|fgrep $1

Sample run:

llama@llama:...code/shell/ppcg72079search$ ./search.sh th thing awesome potato example
thing

With multiple outputs, they will be on separate lines.

tr \  \\n   replace spaces with newlines (equivalent to tr ' ' '\n')
<<<${@:2}   ... with STDIN as all but first argument
|fgrep $1   fgrep for first argument (fgrep is grep w/ "fixed" string, not regex)

Python 2, 42 36 bytes

lambda i,a:filter(lambda v:i in v,a)

Thanks to muddyfish for saving 6 bytes

Test:

a=lambda i,a:filter(lambda v:i in v,a)
a('th', ['thing', 'awesome', 'potato', 'example']) # ['thing']
a('ing', ['thing', 'potato'])                      # ['thing']
a('tat', ['thing', 'potato'])                      # ['potato']
a('tat', ['tato', 'potato'])                       # ['tato', 'potato']

TeaScript, 4 bytes

F@Iσ

Output is cast to string.

Try it online

Explanation

F@  // Filter input 1
 Iσ // Includes input 2

Python 2, 47 bytes

a=input()
print[x for x in input()if x in a]