Most voted "string" questions
A string is a sequence of zero or more characters. It is commonly used to represent text or a sequence of bytes. When marking a question with this tag, also mark with the programming language to be used and the operation being attempted with the string.
Learn more…1,904 questions
Sort by count of
-
4
votes1
answer888
viewsConverting String to Arraylist
I am receiving in my java code a variable with the following value String arquivo = "CNPJ;INSCRICAOESTADUAL;COD_IBGE;DT_OPE;VLR_CARTAO_CRED;VLR_CARTAO_DEB 35083840049;0;4312476;13/01/2018;0.00;66.00…
-
4
votes2
answers1502
viewsIs there a more optimized way to "multiply" a string without using repetition?
I’m creating an algorithm in Javascript, and I’m already finding it very heavy. Now I need a string "multiplied" N times. I wonder if it is possible to do this without using a repeat. For example,…
-
4
votes2
answers267
viewsBehaviour of malloc(1) in C
If I use char *char_commandout = (char *) malloc(1);, the allocated byte will store the " 0" at position 0 of the vector or will allocate a space for the value I want to store (at position 0) and…
-
4
votes1
answer112
viewsHow to print a hexadecimal value in high box?
I made a program in C++ that reads a number and prints it in hexadecimal, follows the code below. #include <iostream> using namespace std; int main(void) { int n; cin>>n;…
-
4
votes3
answers681
viewsExtract date with Regex
I’m trying to extract a date from a string, but I’m not getting it. Example: String stringQualquer = "um teste qualquer12/02/1998 19/09/1880 Nulo"; I want to pick up the first date of this example…
-
4
votes6
answers2089
viewsCheck if a String contains two words
I have a problem with this exercise here: Write a class that validates data (Validacao), with a method to validate a given name (ehNomeValido(nome)). The method must return true pass the following…
-
4
votes2
answers1292
viewsWhat’s best to use, scanf() or get_s()?
Taking the name 'Maria da silva' as an example: scanf() just go read Maria, get_s() will read it all, correct? I’m in doubt of the best use, my college professor says we should clean the buffer to…
-
4
votes2
answers132
viewsSHA512 hexadecimal return
I found an example of encrypting a string with SHA512. public static string HashedString(string text) { SHA512Managed sha512 = new SHA512Managed(); byte[] hash =…
-
4
votes3
answers1001
views(Python) Find words with total vowels being even
I’d like to ask for your help. I have a code in Python where a part is missing: parse the words of a sentence and save the ones that have an even number of vowels. Example: "I came home and went to…
-
4
votes1
answer99
viewsIs it possible to change a String of a method at runtime?
If I have one String fixed within a method is it possible to change it using reflection or something like that? Example: public static void main(String[] args) { String nome = getName(); boolean…
-
4
votes1
answer309
viewsHow to handle a JSON format string?
Let’s say I receive the following content that is stored in a String: { "client_id": 1580, "videos": 4, "remote_urls": [{ "url": "rtsp://aniceurl.com" }, { "url": "rtsp://aniceurl.com" }, { "url":…
-
4
votes2
answers4332
viewsHow to identify a line break character in C?
Problem: Sometimes I get an entry like (and the entrance continues) other times as: (and the entrance continues) That is, I can receive an integer, or two, or three, and then then receive a string…
-
4
votes2
answers214
viewsTrying to understand the Java print
Watch the code right below; public class Dois { public static void main(String[] args) { int a = 3; int b = 4; System.out.print(" " + 7 + 2 + " "); } } The score is 72, but I thought the result was…
-
4
votes2
answers594
viewsWhat is Java Sort?
Every programmer know that a list of arrays are printed in an orderly way, but in the middle of the way sort(). The result of the impression was this: Abacaxi Banana Laranja Manga I thought it would…
-
4
votes2
answers2210
viewsHow to concatenate a char into a string?
I’m trying to copy the char E for the component char of my struct No: void push(Pilha* p, char E) { No* novo = (No*)malloc(sizeof(No)); strcpy(novo->simbolo, E); novo->prox = p->topo;…
-
4
votes0
answers222
viewsTreating JSON Response with Retrofit in Android Studio
To be clear, I am developing a simple application test, where my user type the Cpf of a registered customer and their data as customers appear on the screen. My server returns me a json with a…
-
4
votes3
answers1697
viewsRemove 2 specific characters from a String
Good afternoon ! Devs, I’m having trouble solving the following problem: In a calculator app, calculations always return a Double, which automatically inserts a decimal place even if it is to deploy…
-
4
votes2
answers250
viewsHow to select strings that start with a given word
I’m manipulating a dataframe on R v.3.5.2 and would like to know how I create a new variable called ES_1_4 which has only rows in the column Pathways which has the starting string as its value…
-
4
votes2
answers75
viewsSplit Column into Other Two Lat Long
I have the following datasheets: BIRDS.GENERO SP1 SP2 XLOCAL Thamnomanes caesius glaucus 0°32'S52°12'W Thamnomanes ardesiacus obidensis 0°10'S51°50'W Thamnomanes caesius glaucus 00°53'44"N52°00'08"W…
-
4
votes1
answer203
viewsFunction "strcmp()" working without adding "string. h"
I wrote an algorithm in C that uses the function strcmp(). Even forgetting to add the string.h the algorithm worked. I would like to understand how it worked since I only found this function in the…
-
4
votes2
answers210
viewsImprove function performance that determines whether it is palindromic
Objective: to optimize performance Description of the problem: I have a function that returns me if the word is a palindrome with true otherwise with `false, until then quiet, but need to improve…
-
4
votes2
answers1851
viewsWhat is the problem of using [n]varchar(max)?
Why the practice of using [n]varchar(max) can cause problems? In my scripts whenever I don’t really know what the length of a string and to prevent problems, I have used nvarchar(max). A few days…
-
4
votes3
answers982
viewsConcatenation in Ruby and . object_id
Hello, my friends! I was studying Ruby and reading the concatenation methods I noticed a slight difference. When I tested the first method using "+", I noticed that when using the .object_id it…
-
4
votes1
answer247
viewsUsing replace in a character in the middle of a String to add text before and after the String
I have this expression stored in a String: 1 * Math.pow(x, 3.0) + 4 * Math.pow(x, 2.0) + 1 * Math.pow(x, 1.0) + 27 However, I use a derivation library that only accepts the character ^ to make…
-
4
votes2
answers146
viewsFormat decimal places in Forms
I need to format the decimals and I can’t. What is the correct way to do the formatting in this case? double peso, altura, imc; string nome; nome = txtnome.Text; peso =…
-
4
votes1
answer289
viewsChr$ equivalent function in C#
I’m migrating a chunk of code in Visual Basic 6 and came across the following call: variavel = Chr$(27) & Chr(15) 1 - What would be the equivalent functions in C#? 2 - What is the difference…
-
4
votes1
answer58
viewsString concatenation behavior in C
Why the following C code works? char *str = "A""B"; /* str = "AB" */ However I noticed that it is only in string statements, for example the following would not work: char *a = "A"; char *ab = a…
-
4
votes1
answer84
viewsEntry problem in loop comparing string
I can’t make it into the loop using only the char 'Anunciar', when you put something in, it starts the loop. What should I do? #include <stdio.h> #include <stdlib.h> #include…
-
4
votes2
answers318
views"-" operator cannot be applied to a string
I’m trying to make some changes to a ready code, but I came across a problem with a line of code written in C#: string[] textArray1 = new string[] { -899253461.ToString() }; In this case, Visual…
-
4
votes1
answer113
viewsHow should I assign strings in C#?
As far as I know, System.String no. NET (I don’t know if on other platforms the string type is also like this) is immutable, ie if I do: string a = "texto"; a = "outro texto"; Behind the scenes, by…
-
4
votes2
answers89
viewsChange string characters, except the last 4
The idea of the function is to change the characters of a string (minus the last 4 characters) per "#". I created the function, but I believe I have problems in the logic of the code. function…
-
4
votes2
answers279
viewsHow to divide strings into equal parts
How to divide a texto with or more than 20,000 characters in equal parts and each part containing 5000 characters? (Nodejs) I have that function: textBreak = (data) => { const characterCounter =…
-
4
votes3
answers1145
viewsHow to remove spaces from a string in Python without also removing line breaks?
I need to remove unnecessary spaces from the strings, but not the break between the lines. I have used the command below, which removes the spaces, but also removes the break with the /n. Does…
-
4
votes1
answer213
viewsStackoverflow error when compiling code in C#
I am doing an exercise in C# and I am not able to find the error in my code, because I have already checked the resolution of the problem and I can’t find the difference in the syntax of the code…
-
4
votes1
answer63
viewsFunction to find complete word, but independent of position in string
I’m having trouble using the str_detect to capture part of a text. I need the str_detect take only the word "garlic", but regardless of her position in the string. Ex: "Brazilian garlic", "Brazilian…
-
4
votes0
answers36
viewsWhat is "L" for before a string in C++?
I noticed that some frameworks and Engines require the string to be passed with L before the text. A Irrlicht Engine is an example. myObject->setLabel(L"my string"); What is the purpose of this L…
-
4
votes1
answer304
viewsBinary sum result
A program capable of operating two binary numbers between 0-255. Program input needs to be in binary and output as well. I did it in a way that was working, so that if I pass in binary 1 + 11, the…
-
4
votes1
answer146
viewsWhat is the difference between the "in" operator and the "hasOwnProperty" method in Javascript?
An unexpected behavior (at least for me) occurred with the following excerpt of code that I will demonstrate below: const str = new String('olá SOpt'); console.log('Usando "in"', 'length' in str);…
-
4
votes2
answers94
viewsSpecial characters are not displayed by the console.log
I’m solving a school exercise and I need to print a string with special characters using console.log, however the \ contained in the string are removed when executing the code. In search of the…
-
3
votes2
answers2721
viewsHow to write in a text file concatenating with existing text in Java?
I would like to write in a text file using Java, but whenever I use the functions write of BufferedWriter the previous text is deleted and the new one is written, I would like to keep the old text…
-
3
votes1
answer697
viewsLoad the image bytecode in String and convert to Bitmap in Flash AS3
I need to load the image bytecodes inside a String and then convert to Bitmap. I am using the code below but without success: var urlLoader:URLLoader = new URLLoader(); urlLoader.load(new…
-
3
votes2
answers5124
viewsCopy Strings in C
I have the following two-dimensional matrix of strings. char matriz[linhas][tamanhoDaString] Through the strcpy I copied a string there. char *aux = "abc"; strcpy(matriz, aux); My goal was to put in…
-
3
votes2
answers1455
viewsHow to find special characters that are inside other characters using javascript
I have a string value in json format '{"text": "Look "I" here"}' and I want to change this quote "I" because it will give error in the code. I was thinking of using JSON.parse and loop the items,…
-
3
votes2
answers3335
viewsPrint special characters on windows console
How to print special characters like 'is' and 'ç' on the windows console (printf)?
-
3
votes1
answer2570
viewsWork with Struct and print problem, change Struct and delete Struct
I have a work at the college to do that consists of creating a structure of "Library Register"(cataloging code, name of the work, name of the author, publisher, donated works of each area, number of…
-
3
votes1
answer93
viewsConvert string to array
Guys I get data from my database that comes this way 1,2,3,4,5 And I need to run each number, because each number is a user ID and I want it to show each one separately without comma or anything,?…
-
3
votes1
answer1276
viewsMark (colorize) a string to write to the file
My application searches for a few words in a file. When the program recognizes these words (strings), it should mark it. For example: change the font color or change the word background color. Then…
-
3
votes1
answer465
viewsHow to use java.String.format in Scala?
I’m trying to use the method .format string. But if I put %1, %2, etc. in the string, the java.util exception.Unknownformatconversionexception is released, pointing to a confusing Java code: private…
-
3
votes2
answers87
viewsHow to extract json from a jsonp in a Scala string
I’m using Scala and I have an http response like this: _SS_MainSolrCallbackH( { response: { numFound: 1, start: 0, maxScore: 4.9338827, docs: [ { tipo: "M", id: "mus1933196",a s: 4.9338827, u:…
-
3
votes1
answer136
viewsString array conversion
I have the following array as I turn it into a string. This string would be used to save the products from the shopping cart in Mysql. So they have various snacks and products: products 5,2,5 use…