Tag: string
-
How do I split a string by a character without ignoring trailing split-characters?
7 I have a string similar to the following my_string <- "apple,banana,orange," And I want to split by , to produce the output: list(c(‘apple’, ‘banana’, ‘orange’, "")) I thought strsplit would accomplish this but it treats the trailing ‘,’ like it doesn’t exist my_string <- "apple,banana,orange," strsplit(my_string, split = ‘,’) #> [[1]] #> [1] "apple"…
-
Is there a possibility when calling .ToUpper() that the new string requires more memory?
9 I want to use the the following function in the MemoryExtensions namespace public static int ToUpper(this ReadOnlySpan<char> source, Span<char> destination, CultureInfo? culture) My question now is: am I always safe when destination Span has the length of the source span? e.g. destination = stackalloc char[source.Length]; If no, can someone provide an example which string…
-
Execute a graphql query using painless script, with params having hyphen and space and match a field property with type keyword and text
0 I’m new to graphql and opensearch queries. Here I’m trying to add a filter to existing query for city, my params inside the query are having data with – and spaces. While I’m trying to query it, data is getting filtered only with first word. For example, my params is having an array "cityNames"…
-
Is constructing an object in an argument list and passing a pointer to internal data of the object to the function safe?
8 Is the C++ code below well-formed? Will the std::string get destroyed before or after the function finishes executing? void my_function(const char*); … my_function(std::string("Something").c_str()); c++ string temporary-objects Share Improve this question Follow edited 9 hours ago Evg 25k55 gold badges3939 silver badges8383 bronze badges asked 11 hours ago BlueCannonBallBlueCannonBall 13311 silver badge33 bronze badges 4…
-
How to replace characters in a string one at a time generating new string for each replacement?
6 I have a vector of strings c("YSAHEEHHYDK", "HEHISSDYAGK", "TFAHTESHISK", "ISLGEHEGGGK", "LSSGYDGTSYK", "FGTGTYAGGEK", "VGASTGYSGLK", "TASGVGGFSTK", "SYASDFGSSAK", "LYSYYSSTESK") for each string I would like to replace "Y", "S" or "T" with "pY", "pS" or "pT". But I dont want all the replacements to be in the same final string, I want each replacement to generate a…