How to cut the last field from a shell string
For what it’s worth, a cut-based solution: NEW_LINE=”`echo “$LINE” | rev | cut -d/ -f2- | rev`/”
For what it’s worth, a cut-based solution: NEW_LINE=”`echo “$LINE” | rev | cut -d/ -f2- | rev`/”
This will remove all digits: firstname1 = firstname1.replaceAll(“\\d”,””);
You do any of the following: Use regular expressions. You can use a regular expression with either A negative character class that defines the characters that are what you don’t want (those characters other than decimal digits): private static readonly Regex rxNonDigits = new Regex( @”[^\d]+”); In which case, you can do take either of … Read more
First, get file name without the path: filename=$(basename — “$fullfile”) extension=”${filename##*.}” filename=”${filename%.*}” Alternatively, you can focus on the last “https://stackoverflow.com/” of the path instead of the ‘.’ which should work even if you have unpredictable file extensions: filename=”${fullfile##*/}” You may want to check the documentation : On the web at section “3.5.3 Shell Parameter Expansion” … Read more
Microsoft Connect Discussion Here is some code to workaround: static int CompareStringUsingSortKey(string s1, string s2) { SortKey sk1 = CultureInfo.InvariantCulture.CompareInfo.GetSortKey(s1); SortKey sk2 = CultureInfo.InvariantCulture.CompareInfo.GetSortKey(s2); return SortKey.Compare(sk1, sk2); }
The following site shows an algorithm for computing the longest palindromic substring in O(n) time, and does so by computing the longest palindromic substring at every possible center and then taking the maximum. So, you should be able to easily modify it for your purposes. http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/ EDIT: The first link looks a little shaky upon … Read more
Wow, another gotcha with putting Windows files paths in slashy strings. Nice catch. The gotcha I’ve encountered before was including a trailing backslash on the path, e.g. /C:\path\/, which results in an unexpected char: 0xFFFF error. Anyways, for the sake of an answer, given that Windows paths are case insensitive, why not exploit it for … Read more
You can use the filter function to leave only those keywords contained in content: val match = keywords.filter { it in content } Here match is a List<String>. If you want to get an array in the result, you can add .toTypedArray() call. in operator in the expression it in content is the same as … Read more
You can try this, String fileName = “\\/:*AAAAA?\”<>|3*7.pdf”; String invalidCharRemoved = fileName.replaceAll(“[\\\\/:*?\”<>|]”, “”); System.out.println(invalidCharRemoved); OUTPUT AAAAA37.pdf
I was just researching this myself. I found that System.String.Concat works pretty well, e.g. “abcdef01234567” |> Seq.take 5 |> String.Concat;; assuming that you’ve opened System.