Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with modifying a pattern of strings #1176

Open
yq4103 opened this issue Nov 4, 2022 · 1 comment
Open

Help with modifying a pattern of strings #1176

yq4103 opened this issue Nov 4, 2022 · 1 comment

Comments

@yq4103
Copy link

yq4103 commented Nov 4, 2022

Can someone help me with the spec for this transformation? Thanks a lot.
The length of the string may change, and the number of "." is also not fixed. After the jolt transform, I only want to keep the part of the string which comes after the last "."
So I don't think substring is gonna work in this case.

JSON input:
{ "myString": "keep.only.the.last.word" }

Expected output:
{ "myString": "word" }

@charlesardsilva
Copy link

Hi, you can do this:

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "myString": "=split('\\.',@(1,myString))"
    }
  },
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "myString": "=lastElement(@(1,myString))"
    }
  }
]

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

No branches or pull requests

2 participants