Reputation: 2001
I want to write a regular expression that can match the following strings:
OFF
ON
String
Valve
I was thinking to write ^(?<arrivingString>[a-zA-Z]{?})$
.
Now I don't know what to write within the curly brackets, as the value of arriving string is different and random.
Thanks
Upvotes: 0
Views: 83
Reputation: 3400
^(?<arrivingString>(OFF|ON|String|Valve)).*
This matches those 4 words only provided:
This Regex will match every line in it's entirety provided it starts with any of those 4 strings. The captured group arrivingString
will contain whichever of the four words was found.
Upvotes: 2