0

I have the following code:

userInput = "develop-feature-21"
entry = "develop-feature-**"
entry = entry.replace("**", ".*");
println (userInput ==~ "$entry") // ------> false

I basically want to replace ** and add in a valid regular express .* to find all entries of develop-feature, but the problem I am having is evaluating a RegEx expression within a string.

$entry becomes develop-feature-.*, but how do I tell groovy to then evalulate .*?

1
  • You must have came to groovy from perl Commented Jul 19, 2021 at 18:12

1 Answer 1

2

i've seen this in old version of groovy. i have 2.5 and your code works for me.

you could try to use

println (userInput ==~ entry)

instead of

println (userInput ==~ "$entry") 
userInput = "develop-feature-21"
entry = "develop-feature-**"
entry = entry.replace("**", ".*");
println (userInput ==~ entry) //----------> true
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.