Forum Discussion

Tau34RUS's avatar
Tau34RUS
New Contributor
12 years ago

[Resolved] How to Replace part of a variable

Hello.

I was not able to fugure out how to change variable like
"something_that_i_need&smth_that_i_dont_need"
into
something_that_i_need

folowing regular expression works fine in Notepad++
replace (&)(.*) with nothing

How can I use the same with groovy?
  • Tau34RUS's avatar
    Tau34RUS
    New Contributor
    Just figured out it. Here is a samlpe

    content = '123456&654321'
    content = content.replaceAll(/(&)(.*)/, "" )


    This wil result 123456
    the only thing you need to use regular expressions in replace - add / /