How to match the string "Net Amount" (between Net and Amount there can be any number of spaces, including zero) with net amount
?
Spaces between these two words can be any whitespace and exact matching of two string should be there. But Net Amount (first string with spaces) can be part of any string like Rate Net Amount
or Rate CommissionNet Amount.
The match should be case-insensitive.
Use regular expressions. Have a look at the System.Text.RegularExpressions
namespace, namely the Regex
class:
var regex = new RegEx("net(\s+)amount", RegexOptions.IgnoreCase);
// ^^^^^^^^^^^^^^^
// pattern
The argument string is what is called the regular expression pattern. Regular expression patterns describe what strings will match against it. They are expressed with a specialized syntax. Google for regular expressions
and you should find plenty of information about regexes.
Usage example:
bool doesInputMatch = regex.IsMatch("nET AmoUNT");
// ^^^^^^^^^^^^^^^^^
// test input
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With