After collecting user input for various conditions like
- Starts with :
/(^@)/
- Ends with :
/(@$)/
- Contains :
/@/
- Doesn't contains
To make single regex if user enter multiple conditions,
I combine them with "|"
so if 1 and 2 given it become /(^@)|(@$)/
This method works so far but,
I'm not able to determine correctly, What should be regex for 4 the condition? And combining regex this way work?
Update: @(user input) won't be same for two conditions and not all four conditions always present but they can be and in future I might need more conditions like "is exactly" and "is exactly not" etc. so, I'm more curious to know this approach will scale ?
Also there may be issues of user input cleanup so regex escaped properly, but that is ignored right now.