Skip to content

Function proposal - split() #3

@glenveegee

Description

@glenveegee

Given a string - split string on a pattern:

For example in Javascript one might implement it as follows:

registerFunction(
  'split',
  ([splitChar, toSplit]) => {
    return toSplit.split(splitChar);
  },
  [{ types: [TYPE_STRING] }, { types: [TYPE_STRING] }],
);

Examples:

jmespath.search("foo-bar-baz", "split('-', @)")
// OUTPUTS: [ 'foo', 'bar', 'baz' ]

jmespath.search("foo-bar-baz", "split('*', @)")
// OUTPUTS: [ 'foo-bar-baz' ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions