-3

I need to select the substring of a text from an given keyword. For example

Str= 'book, painting'

I need to get output like ', painting'

So i gave regular expression like (•*)(\, •*) and collect group2 as an output.

But if the input is

Str= 'book, painting, instrument'

I am getting ', instrument' as an output but i should get ', painting, instrument'.

3
  • I am doing this in Replace in string step in pentaho data integration Commented Jan 5, 2024 at 16:51
  • This is an sample string and my code has name in this format so i need to get all the secondary names which will be after the first comma.. So there may be many names after primary name so i am not sure how many I can expect after first comma Commented Jan 5, 2024 at 17:01
  • Have you tried this? (•*?)(\, •*) Commented Jan 5, 2024 at 23:44

1 Answer 1

1

To specify that the regex should start matching at the start of your text, use "^". Similarly, "$" can be used to match the end of your text, grabbing until the end of the string.

Your first reference should explicitly exclude commas, to ensure it only grabs the first column.

 ^([^,]*)(\, •*)$
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.