What is correct syntax for split function in Splunk eval?

SPLK-1004 By islever Editorial Last updated

Short answer

B | eval areaCodes - split(phoneNumber, “-“)

Question

Which of the following is valid syntax for the split function?
  1. | eval split phoneNumber by “-“ as areaCode
  2. | eval areaCodes - split(phoneNumber, “-“) Correct Answer
  3. | eval phoneNumber split(“-“, 3, areaCodes)
  4. | eval split(phoneNumber, “-“, areaCodes)

Key Takeaways

The question tests your ability to recall the exact eval function syntax, and the common trap is confusing assignment (=) with a hyphen or mixing argument order.

The correct answer is B, though it must use an equals sign: | eval areaCodes = split(phoneNumber, "-"). Community consensus confirms that the split function takes a field and delimiter and returns multiple values.

Common mistake: The most common mistake is choosing option B without noticing that it originally says `areaCodes - split(...)` instead of `areaCodes = split(...)`. This makes the expression invalid because `eval` requires a field assignment using `=`.

Expert Analysis

Why the Answer Is Correct

B is the only option that resembles the proper eval expression form. In Splunk, the split function is used as split(field, delimiter) and returns a multivalue. Commenters note that B is correct only if the hyphen is replaced with =, as in | eval areaCodes = split(phoneNumber, "-").

Why the Other Options Are Wrong

A is invalid because eval does not support split phoneNumber by "-" as a bare function call. C puts the arguments in the wrong order and also does not assign to a field correctly. D uses a function call on the left side of a comma and lacks the field assignment syntax that eval requires.

Community Comment Notes

Commenters unanimously agree on B and highlight the typo in the printed option, noting that the hyphen should be an equals sign. One commenter suggests correcting it to | eval areaCodes = split(phoneNumber, "-") before selecting B, while another describes the same fix.

Official Reference

Exam Strategy

In the exam, check every character in eval expressions — a common trap is a hyphen instead of an equals sign. Remember the exact syntax: | eval new_field = split(existing_field, delimiter).

Community Votes

B
100%

100% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.

Discussion 4 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 4

  1. Derag 👍 2
    No, the correct answer is B. This syntax splits the phoneNumber field using the "-" delimiter and creates a new field areaCodes with the split values.
  2. c1c8784 👍 1 Answered B
    B. Is the only correct answer, but needs the '-' in "areaCodes - split(phoneNumber, "-")" to be changed to "areaCodes = split(phoneNumber, "-")" As a50b9c8 suggests.
  3. a50b9c8 👍 1 Answered B
    The answer is B but replace - to = to become ( |evan area=split( x , delim)
  4. teeec 👍 1 Answered B
    | eval areaCodes = split(phoneNumber, "-")

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Practice All SPLK-1004 Questions

Access 130 questions with complete answers and detailed explanations.

View Full SPLK-1004 Practice Test →

← Back to SPLK-1004 Study Guide