adding variables in a regular expression to make it dynamic in java
问题 I need to form a regular expression in order to check the outputs of a response log. The log file will always be different based on the input. Thus, I want to create a dynamic regular expression based on the input to the function. I may need to pass variable number of variables at a time for comparison, so how can that 'or' factor be inserted in the regex? Is it possible to create such a regular expression in Java, and how should I go about it? 回答1: Yes, the regex is only a string, you can