ArrayList’s custom Contains method

here’s some code that might demonstrate how it works out: import java.util.ArrayList; class A { private Long id; private String name; A(Long id){ this.id = id; } @Override public boolean equals(Object v) { boolean retVal = false; if (v instanceof A){ A ptr = (A) v; retVal = ptr.id.longValue() == this.id; } return retVal; } … Read more

Using contains() in LINQ to SQL

Looking at the other attempts saddens me 🙁 public IQueryable<Part> SearchForParts(string[] query) { var q = db.Parts.AsQueryable(); foreach (var qs in query) { var likestr = string.Format(“%{0}%”, qs); q = q.Where(x => SqlMethods.Like(x.partName, likestr)); } return q; } Assumptions: partName looks like: “ABC 123 XYZ” query is { “ABC”, “123”, “XY” }

IF a cell contains a string

SEARCH does not return 0 if there is no match, it returns #VALUE!. So you have to wrap calls to SEARCH with IFERROR. For example… =IF(IFERROR(SEARCH(“cat”, A1), 0), “cat”, “none”) or =IF(IFERROR(SEARCH(“cat”,A1),0),”cat”,IF(IFERROR(SEARCH(“22″,A1),0),”22″,”none”)) Here, IFERROR returns the value from SEARCH when it works; the given value of 0 otherwise.

Is there a regex to match a string that contains A but does not contain B [duplicate]

You use look ahead assertions to check if a string contains a word or not. If you want to assure that the string contains “Android” at some place you can do it like this: ^(?=.*Android).* You can also combine them, to ensure that it contains “Android” at some place AND “Mobile” at some place: ^(?=.*Android)(?=.*Mobile).* … Read more

tech