Printing ” (double quote) in GoLang
This is very easy, Just like C. fmt.Println(“\””)
This is very easy, Just like C. fmt.Println(“\””)
For what it’s worth, a cut-based solution: NEW_LINE=”`echo “$LINE” | rev | cut -d/ -f2- | rev`/”
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
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.
Possible solutions to codepoint slicing I know I can use the chars() iterator and manually walk through the desired substring, but is there a more concise way? If you know the exact byte indices, you can slice a string: let text = “Hello привет”; println!(“{}”, &text[2..10]); This prints “llo пр”. So the problem is to … Read more
You have to convert the string to UTF-8 data first let string = “foo bar” let data = string.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)! and then write it to the output stream let outputStream: NSOutputStream = … // the stream that you want to write to let bytesWritten = outputStream.write(UnsafePointer(data.bytes), maxLength: data.length) The UnsafePointer() cast is necessary because … Read more
Either of the these will do: grep -v “def” input_file | grep “abc” or grep “abc” input_file | grep -v “def” The following will also preserve coloring if you only want to see the output on stdout: grep –color=always “abc” input_file | grep -v “def” The -v option (stands for “invert match”) tells grep to … Read more
$pos = $name.IndexOf(“;”) $leftPart = $name.Substring(0, $pos) $rightPart = $name.Substring($pos+1) Internally, PowerShell uses the String class.
A logical solution would be to use *string as mentioned by Ainar-G. This other answer details the possibilities of obtaining a pointer to a value (int64 but the same works for string too). A wrapper is another solution. Using just string An optional string means a string plus 1 specific value (or state) saying “not … Read more