AI Native 分级编程挑战

第2级 · 实战 · 状态与工作流程

解析带引号的CSV

处理逗号、换行和引号转义。

题目说明

编写 function solution(text)。输入输出均为 JSON 值,不要修改输入数组或对象。不支持外部库、网络访问及异步函数。 text is valid CSV. Separator is comma; records use LF, CRLF or CR. A field may be fully double-quoted; inside it retain commas/newlines and unescape doubled quotes. Do not trim whitespace. A terminal record separator adds no phantom row. Empty text returns []; a blank record is ['']. Return arrays of field strings. Malformed CSV is outside the contract. 输入范围:每个输入数组最多50,000项,每个字符串最多1,000个字符。数字必须有限,整数及整数累计结果在JavaScript安全整数范围内。其他类型和有效性遵循上述规则。

输入输出示例

示例 1

函数参数

[
  "a,b\n1,2"
]

返回值

[
  [
    "a",
    "b"
  ],
  [
    "1",
    "2"
  ]
]
示例 2

函数参数

[
  "\"a,b\",\"x\"\"y\"\r\n3,4"
]

返回值

[
  [
    "a,b",
    "x\"y"
  ],
  [
    "3",
    "4"
  ]
]
示例 3

函数参数

[
  "서울,\"공백\""
]

返回值

[
  [
    "서울",
    "공백"
  ]
]
Practice has no points, deadline or submission cap. Use AI and search freely. Sign in to run public examples, or verify locally.

55 / 20,000字符

Add your test · optional

Enter a JSON argument array in text order. Your test runs alongside the three examples.

Save both files in one folder and run this command with Node.js. Read the checks field for individual example results.

node verify-csv-parser.mjs
문의하기

서비스명: 포트포올
문의는 운영자에게 이메일로 전송됩니다.

이메일과 문의 내용은 답변을 위해 운영자 및 메일 발송 서비스로 전송됩니다. 비밀번호·결제정보·민감한 개인정보는 입력하지 마세요.