Splitting Strings #13592
Splitting Strings
#13592
-
Say I have a string parameter, "foo_bar". What's the simplest way that I can split that string according to the underscore delimiter? My method right now is to run separate script tasks to grab the first, then second part of the string. I'm not sure how I can get a single script task to output two results (and then be able to use then in subsequent steps). Either way, this seems a bit clunky.... Is there a jsonPath/expr solution for this? Or something easier? |
Beta Was this translation helpful? Give feedback.
Answered by
jswxstw
Sep 13, 2024
Replies: 1 comment 1 reply
-
Here is an example with metadata:
name: test-split
namespace: argo
spec:
arguments:
parameters:
- name: message
value: foo_bar
entrypoint: argosay
templates:
- name: argosay
inputs:
parameters:
- name: first
value: '{{=split(workflow.parameters.message, "_")[0]}}'
- name: second
value: '{{=split(workflow.parameters.message, "_")[1]}}'
container:
name: main
image: argoproj/argosay:v2
command:
- /argosay
args:
- echo
- '{{inputs.parameters.first}} {{inputs.parameters.second}}' |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jrussell9000
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is an example with
expr
: