Skip to content

Conversation

@fartinmartin
Copy link
Contributor

The current types for String.split only allows for string delimiters:

/**
* Splits a string into a group of substrings, places those strings in an array, and returns the array.
* The substrings are created by breaking the original string at places that match delimiter, the delimiter characters are removed.Returns an array whose elements are the substrings.
* @param delimiter Specifies the string to use for delimiting. If delimiter is omitted, the array returned contains one element, consisting of the entire string.
* @param limit
*/
split(delimiter: string, limit?: number): string[]

But this will work:

// test-in-ae.jsx
alert("Hello there, pal!".split(/[\s,]+/).length)

This PR adds RegExp to type:

split(delimiter: string | RegExp, limit?: number): string[]

@zlovatt zlovatt merged commit 3d27f15 into docsforadobe:master May 17, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants