How do I put a regular expression to check if a string starts with certain pattern and is NOT ending with certain pattern.
Example:
Must StartsWith: "US.INR.USD.CONV"
Should not end with: ".VALUE"
Passes Regex: "US.INR.USD.CONV.ABC.DEF.FACTOR"
Fails Regex Check: "US.INR.USD.CONV.ABC.DEF.VALUE"
I am using C#.
You can use this regex based on negative lookahead:
^US\.INR\.USD\.CONV(?!.*?\.VALUE$).*$
^US\.INR\.USD\.CONV
- Match US.INR.USD.CONV
at start of input(?!.*?\.VALUE$)
- Negative lookahead to make sure line is not ending with .value
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments