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
-
2
votes3
answers548
viewsError using scanf("%[ n]") in sequence
#include <stdio.h> typedef struct person{ char name[100]; char address[100]; int age; } Person; int main() { Person pessoa; printf("Digite seu nome:\n"); scanf("%99[^\n]", pessoa.name);…
-
2
votes1
answer889
viewsconvert whole to java string
How do I convert the Integer to String type in Java? The variable matricula is declared as whole, but to show it on the screen it asks to convert it to String.…
-
2
votes2
answers174
viewsFormatting values per Razor pages
I’m having problems formatting a variable through the Razor pages in C#. Let’s say that a variable called value receives the number 9.5723 (real nine and 57 cents), I need all decimals above 2 are…
-
2
votes1
answer410
viewsWhy can’t I make an "append()" on a list formed from a "Join()"?
I started creating a list in Python leaving each element below the other through the join(). Then I tried to add an element to the list through append(): abc = '\n'.join(['a','b', 'c'])…
-
2
votes1
answer1262
viewsWhat does "string" mean?
String in English means line. What this has to do with programming strings? Why do they call themselves that?
-
2
votes1
answer142
viewsjson.loads Jsondecodeerror
The cookies posted here, there is no validity, so if you want to do evil, look for another I have these cookies I saved using the PHP language…
-
2
votes2
answers242
viewsFunction in C that deletes a given string
I need to create a function that deletes in s1 the first occurrence of s2. char *StrlDelStr(char *s1,char *s2) Example: char *s = "O rato roeu a rolha da garrafa"; StrlDelStr(s, "xy"); -> "O rato…
-
2
votes1
answer224
viewsHow do I play the variable within a text in "Messagebox.Show" of a "case" on the "switch" command?
I’m doing a program interface on switch using C# to find out what a couple’s wedding anniversary is, only that I do not know how to insert the result variable for the case default if the marriage is…
-
2
votes2
answers78
viewsInvert a string correctly
I cannot print the vector backwards, in this case, the word typed has to have exactly 6 letters. It follows the code: #include <stdio.h> #include <stdlib.h> int main() { char…
-
2
votes2
answers146
viewsHow to give an UPDATE by swapping for ?
I am trying to perform an UPDATE to change the \\ for \ , as in SQL below: UPDATE `post` SET `descricao`= replace(descricao, '\\','\'); I was told that Mysql does not accept regular expression on…
-
2
votes1
answer356
viewsDynamic string allocation in an array
I have a problem to store a vector dynamically need to save 10 names but I’m not knowing how to access this data for later printing follows my attempt #include <stdio.h> #include…
-
2
votes1
answer59
viewsSegmentation Fault na strcat()
Recently I started learning about function strcat() and developed the code below, but I’m encountering a Segmentation fault: #include <stdio.h> #include <stdlib.h> #include…
-
2
votes1
answer56
viewsHow to make a condition with operators "+", "-", "*","/"
I have the following code: print ("Primeiro Valor: "); $valor1 = <STDIN>; print ("Segundo Valor: "); $valor2 = <STDIN>; print ("Operador: "); $op = <STDIN>; if ($op == "+") {…
-
2
votes1
answer540
viewsWhy does Python consider an empty string ('or "") to be present in a simple variable with characters, but not in a composite one?
When doing basic programs asking for user input, and testing if it is empty with in because of another variable that defines possible inputs, I come across the following: if '' in 'abc': print('not…
-
2
votes2
answers329
viewsFunction that returns uppercase consonants
the function receives a sentence as input and returns the sentence with all its consonants in uppercase. def teste(frase): i=0 while i<len(frase): if frase[i]in 'bcdfghjklmnpqrstvxwyz':…
-
2
votes1
answer69
viewsObjective of str()
I’d like to know what role the function plays str() on line 33(code does not work without this function, gives this error: Typeerror: Unsupported format string passed to list.format) jogadores =…
-
2
votes3
answers1489
views -
2
votes3
answers114
viewsHow to remove only spaces between words/letters?
Supposing I have a string: str = ' p s i c ó l o g o '. Note that the string has a space before the letters, a space between the letters and a space after the letters. What I want is for the spaces…
-
2
votes2
answers263
viewsIn Python, search a string from the information of a column?
I’m at Jupyter Notebook working with Python. Has a dataframe with the name and text fields, in the text, which is a txt loaded, I want to search if there is the string that is exactly the value in…
-
2
votes2
answers148
viewsString handling with Regex
I have the following string: const string = 'Isto é uma frase $[var_test["aaaa"].bbb], mais coisas $[var_test["ccc"].ddd].eee.fff mais coisas.' The dynamic elements are: var_test | aaa | bbb | ccc |…
-
2
votes2
answers2053
viewsEoferror: EOF when Ading a line
I’m doing a program that’s a resolution of this issue of the Computer Olympiad. A, B, C = input("A").split(), input("B").split(), input("C").split() A, B, C = int(A[0]), int(B[0]), int(C[0]) if A…
-
2
votes1
answer35
views -
2
votes2
answers389
viewsHow to display user name initials without their connectors?
From a name entered by the user, display your initials but without your connectors. For example: josé da silva -> JS I was able to generate the code to print the initials but I’m not getting the…
-
2
votes1
answer69
viewsIn R, is there a difference between double and single quotes?
I am starting my learning in R and would like to know the difference between creating strings using single or double quotes. For example: texto1 <- "isso é um texto" texto2 <- 'isso é um…
-
2
votes1
answer95
viewsConsulting previous index in Python
That question is a continuation of this here As previously reported, I have a script that does a txt search for a keyword (APPLE) and if it is true, it alters another part ("00" or "01" or "02") of…
-
2
votes1
answer705
viewsHow to remove blanks
I have a list and need to remove blanks. I am using replace, but does not take the space from the beginning of the string after the minus sign, only from the end. This space is not a character?…
-
2
votes2
answers342
viewsValidate an expression based on which parentheses should close
I’m solving a Python exercise where I had to validate an expression based on which the parentheses should close right: Create a program where the user type an expression that uses parentheses. Your…
-
2
votes1
answer27
viewsChange/ abbreviate words from a data set
Is there a function in the R that can change one or more words in my dataset? Example, change the word São Paulo for SP.
-
2
votes1
answer27
viewsError reading Localstorage array
Hello, I have an array and the user can shuffle the order of the items: Blusas = ['verde','azul','amarela','rosa','laranja','preta','roxa','vermelha',] After shuffling, this is the update capture…
-
2
votes2
answers71
viewsHow to extract substring in string array with Javascript using match?
I have to manipulate a data in the following format: ["nome <email desse nome>"], an array with several strings in the same format. I want to extract in another array only the emails, without…
-
2
votes1
answer44
viewsHow do I return a string from a char function? The returned value is NULL
I am having problems with creating a char function that returns a string typed by the user. I call her in a registration method and try to play for the struct variable. cadastrarLocacaoNome();…
-
2
votes1
answer89
viewsFunction that takes a string and converts it to uppercase letters gives error
My code performs double loop for and no longer executes even what I put after the function call stringToUpper() within the main(), or what I put after the loop for. #include <stdio.h> #include…
-
2
votes2
answers258
viewsHow to divide the value of an element of a column by delimiter (p.e "|") in pandas?
Let’s say we have the following column: coluna1 ola | 52 hey sou ja da |5 24g The expected output would be: coluna1 ola 52 hey sou ja da 5 24g So far, I’m trying string manipulation with split and…
-
2
votes2
answers53
viewsHow can I exchange elements of a string using the values of an object as argument?
I have this code: const operators = { plus : '+', minus : '-', multiplied : '*', divided : '/' } let question = 'What is 4 plus 6?'; let matchs = question.match(/\d|plus|minus|multiplied|divided/g);…
-
2
votes1
answer83
viewsHow do I return a character from a string in the Python function with Websockets and json library?
I’m new to Python and I have a question I’ve been trying to figure out for a long time. I’m creating a tick analysis program from an investment site, and I want to extract the value of a certain…
-
2
votes0
answers53
viewsWhat makes this C program unusable when compiled in different versions of GCC or Clang?
This C language program is compiled in all versions of GCC without any error message, but specifically in GCC 6.3 and 8.3, the executable produces totally inconsistent results. In GCC 8.1 and 10.2…
-
2
votes1
answer145
viewsHow to transform an array with strings(list) into an integer array in Python?
I’m new to python programming. I came across today the challenge of picking up a vector (ex:V1== ['MESA 11 22 33 44 ']) in which all its elements are in string format (as if they were one, only…
-
2
votes1
answer37
viewsSubstring does not return empty string
I have the following text file called fullResponse <Sum> [stat]player_ammo_restored = 3447 <Sum> [stat]player_climb_assists = 2102 <Sum> [stat]player_climb_coops = 2612 <Sum>…
-
2
votes1
answer115
viewsHow to remove double quotes from the beginning and end of a Dart variable?
Speak devs, all right? I am unable to remove double quotes from the beginning and end of a Dart variable. I post to my Web API and receive a JWT Object. I only need the value of the object, without…
-
2
votes1
answer218
viewsCheck if it is vowel or consonant and if it is lowercase or uppercase without using ready-made functions
I am developing two functions in C language, the first to check whether a letter is a vowel or a consonant, without using any ready function. The first is working. The second function checks whether…
-
2
votes1
answer68
views"strlen()" works with literal but not string type variable
I have this code: #include <iostream> #include <string.h> using namespace std; int main() { int len = strlen("Teste"); cout << len << endl; return 0; } That generates the…
-
2
votes1
answer70
viewsDoubt about C++ pointers
Why if a char type raw pointer is pointing to some character of a std::string and print this pointer without the asterisk (*) it will show the rest of the string from the character it is pointing…
-
1
votes4
answers3813
viewsHow to check if one string is contained in another?
I have several strings in one ArrayList. I would like to know how to return a string from that list that contains another one that was passed. For example, if I pass one String "Bean", want to…
-
1
votes2
answers1632
viewsRegex to pick numbers between the second and third "/"
Let’s say I have the following string /product/976935/ How would I make a regex to return only the numbers between the second and third bar? The amount of numbers varies so it’s no use just…
-
1
votes2
answers146
viewsText problem cut when creating text file
I need to create a file that contains PHP code. This code comes from a string like "<?php class foo{ } ?>" but when I give a echo she just cuts out the reserved words. How to turn the string…
-
1
votes3
answers243
viewsRegex for hexadecimal colors
I have a small doubt: I have a regex that captures in 3 groups (2 values per group) of certain color, but this when I have 6 values(excluding the #), I would like to know how to implement to catch 1…
-
1
votes3
answers2537
viewsDetect no characters in a string
How do I make to detect the existence noncharacters like this in a string? �*�v��R�<�
-
1
votes1
answer128
viewsWhy does email get bad format when putting HTML in the body?
I have a jQuery editor that sends a string in HTML format to my input as follows. <p class="MsoNormal" style="text-align: justify; text-autospace: none;"><span style="font-size: 10.0pt;…
-
1
votes2
answers1176
viewsWhy can’t I read a string on the console?
I’m trying to read a string typed into the console, which is halfway through the code, but what happens is it goes right through and displays the final information. using System; namespace Viernes {…
-
1
votes2
answers1263
viewsConvert a string url to hyperlink
Works for several links but if I put the same 2x link in the string does not work as do? function MontarLink($texto) { if (!is_string ($texto)) return $texto; $er =…