/^[a-z][ ][=][>][ ][a-z?][.?][a-z0-9]+[ ][=][ ]['?][a-z0-9]+['?]]/i
I'm trying to figure out how to get a rexex pattern that would recognize a string of lambda syntax (used in c#)
In the case of strings
"p => p = 'some random string'" //Must alow for single quotes
In the case of number or boolean values
"p => p = true" /*or*/ "p => p = 25" //Must allow for a string without single quotes with no whitespace at all in the event there are no single quotes
Also it must allow for a single '.' in the letter chosen to the left of the '=' sign
"p => p.firstName = 'Jack'"
How can I modify my regex to fulfill the following requirments
- start off with any letter
- followed with a mandatory space
- followed by a mandatory string '=>' (without single quotes)
- followed by a mandatory space
- followed by the same letter in the step 1 (or at least a single character)
- followed by a period character (optional)
- followed by any set of alphanumberic characters (required if there is a period from step 6)
- followed by a space
- followed by an equals sign
- followed by a space
- followed by any alphanumeric set of characters along with single quotes (but only if the single quotes encompass the set of alphanumeric characters)
static bool greaterThanTwo(int arg)is a predicate. Do you mean lambda predicates:List<int> newList = list.FindAll(i => i > 2);