C# enum contains value

Why not use Enum.IsDefined(typeof(myEnum), value); BTW it’s nice to create generic Enum<T> class, which wraps around calls to Enum (actually I wonder why something like this was not added to Framework 2.0 or later): public static class Enum<T> { public static bool IsDefined(string name) { return Enum.IsDefined(typeof(T), name); } public static bool IsDefined(T value) { … Read more

What is the idiomatic scala way of finding, if a given string contains a given substring?

If you want to do it with maximum efficiency, you may have to write it yourself (or find a good substring searching algorithm somewhere). If you just want it to work at all, then in Scala: scala> “Finding needle in haystack” contains “needle” res0: Boolean = true scala> “Finding needle in haystack” indexOf “needle” res1: … Read more

Use string.Contains() with switch()

Correct final syntax for [Mr. C]s answer. With the release of VS2017RC and its C#7 support it works this way: switch(message) { case string a when a.Contains(“test2”): return “no”; case string b when b.Contains(“test”): return “yes”; } You should take care of the case ordering as the first match will be picked. That’s why “test2” … Read more

jQuery :contains selector to search for multiple strings

Answer To find li‘s that have text containing BOTH Mary AND John: $(‘li:contains(“Mary”):contains(“John”)’) To find li‘s that have text containing EITHER Mary OR John: $(‘li:contains(“Mary”), li:contains(“John”)’) Explanation Just think of the :contains as if it was a class declaration, like .class: $(‘li.one.two’). // Find <li>’s with classes of BOTH one AND two $(‘li.one, li.two’). // … Read more

How to use regex in XPath “contains” function

XPath 1.0 doesn’t handle regex natively, you could try something like //*[starts-with(@id, ‘sometext’) and ends-with(@id, ‘_text’)] (as pointed out by paul t, //*[boolean(number(substring-before(substring-after(@id, “sometext”), “_text”)))] could be used to perform the same check your original regex does, if you need to check for middle digits as well) In XPath 2.0, try //*[matches(@id, ‘sometext\d+_text’)]

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)