Originally there was a string whose contents matched, but now this string has been changed to another look. However, the old version of string matching is also supported for clients that have already been released.
Old string: android/360 1.0
New string: android/aaa/360/1.0
Now I want to write a regular expression that can match both the old string and the new string.
Is there any way to choose one of the expressions according to a certain condition?
Old expression matches regular:
Old regular test string
android coco/360 1.0
New expression matches regular:
New regular test string:
How can a regular one support both the new and the old?
([iOS|android]*)[\\s|\\S]coco/[([\\S\\s]*)\\s([\\S]*)] `**|**` [([\\S]*)/([\\S]*)/([\\S]*)/([0-9])]
Similar to the above wrong regular thinking. How to write?
The difference between two strings like yours is already very big, so there is no need to compress them into a regular inside. It is more appropriate to directly divide them into two regular judgments.
Regular inside does not choose the definition of matching rules according to the conditions. What is used in your case
|To do or match. The effect is no different from using twice regularization.