Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140788

Regex optional substring in the pattern

$
0
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.


Viewing all articles
Browse latest Browse all 140788

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>