0

I have a string as Failed to acquire capacity on the hall And sometimes I might also get Failed to acquire new capacity on the hall. So to cover both the cases I want to make new as optional.

So I grouped new with ? as (new)? in the pattern as below

pattern : failed to acquire (new)? capacity.

But its not working as expected, i.e matching Failed to acquire capacity on the hall even though new is there or not. Ref: https://regex101.com/r/2YhjKc/1

What is the mistake I am doing here ?

Thank you.

1
  • you have an extra space after new. Include the space or remove it: failed to acquire (new )? capacity Commented Jan 30, 2020 at 3:30

1 Answer 1

4

The word new is also surrounded with whitespace, which you should also take into account, e.g.

failed to acquire\s+(new\s+)?capacity

Demo

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.