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
-
6
votes2
answers897
viewsHow to filter items that do not contain a word in a list?
I have a: List<Grupos> lista = new List<Grupos>(); And I have this code var txtFiltro = "noivas,unhas"; var palavrasFiltro = txtFiltro.ToLower().Split(','); matches = lista.Where(x =>…
-
6
votes3
answers413
viewsHow to replace dynamic chunk {{chunk}} of a string in C#?
I get a string dynamically generated example: "Dynamic text {{parametro1}} plus a piece of text {{parametro2}}". I have in C# a code similar to this: where the name is the same that is between keys…
-
6
votes4
answers14489
viewsInvert string in C
I’m trying to reverse a string in C but the function is clearing it: for(i = 0; i < (int)(size/2); i++) { tmp = buffer[i]; //armazena o character inicial buffer[i] = buffer[size - i]; //Troca o…
-
6
votes2
answers113
viewsIs it possible to access the same argument twice in sprintf?
In PHP times the function sprintf. With it we can format the values sequentially passed from the second parameter. For example: sprintf('Meu nome é %s e tenho %d anos de idade', 'Wallace', '26') The…
-
6
votes5
answers497
viewsPrint string in reverse
Why can’t I print that string in reverse? I know there is possibility to use another simpler way, but I want to understand the error. static void Main(string[] args) { string frase = "Diego lima de…
-
6
votes1
answer1950
viewsHow do I save a string of indefinite size to a structure?
#include <stdio.h> #include <stdlib.h> #include <string.h> struct Ecoponto{ int codigo; int contentores[3]; char cidade[20]; char *rua; int nporta; }; int main(int argc, char**…
-
6
votes1
answer172
viewsCheck string Regex C#
I have a string that can only be composed by X capital and by -. Example : X-XX-XX or else X-X-X-XX-XXX. Where each - a group would be counted and each X one digit. Example 1: the string X-XX-XX has…
-
6
votes1
answer7278
viewsHow to use the function toupper() in char in C?
I’m creating a variable: char nome[20]; After this, I am asking the user to enter a name: printf("Digite um nome : "); scanf("%20s",&nome); And I’m checking to see if the name is correct:…
-
6
votes2
answers209
viewsIs there a function that fills a string to a certain length?
I’d like to fill out a string until it reaches a certain length. There is some function capable of doing this? It would be something like the PadLeft(Int32,Char) and PadRight(Int32,Char) of the C#.…
-
6
votes2
answers930
viewsRemoval of excess whitespace
How to remove white spaces inside a string? It would be in the sense of removing spaces from a text string, with the exception of simple spaces between words. As the Excel "tidy" function.…
-
6
votes4
answers2533
viewsHow to split a string every 2 characters?
I’m trying to split a string every two characters, but I don’t have a delimiter and I need to use the whole string. Example: String exemplo= 99E65A78 String ex1= 99 String ex2= E6 String ex3= 5A…
-
6
votes1
answer1909
views -
6
votes1
answer56
viewsWhen to choose between using a string wide or not?
When using a string wide (std::wstring) or a string normal (std::string)?
-
6
votes5
answers4944
viewsFunction to check palindrome
I have the challenge of writing a code to check if a text is a palindrome or not. I haven’t finished the code, at the moment, it’s like this: function checkPalindrome(str) { var direita = [];…
-
6
votes4
answers1049
viewsString list + . Split()
The command string.Split() separates a string in a array of the kind string[]. How to use the string.Split() to separate strings in a list List < string>?…
-
6
votes3
answers20560
viewsPick first and last name and abbreviate middle names only with the initial
I would like to address the following string: string nome = "Rafael Rodrigues Arruda de Oliveira" With the following criteria:: Keep first and last name; Abbreviate the other names (middle names)…
-
6
votes1
answer196
viewsWhat is the difference between performance between different types of string concatenation?
I know 4 different types of concatenation of string in the c#: // string Interpolation $"valor {variavel} R$"; // Verbating string @"texto qualquer pula a linha e continua o texto"; // concatenar 2…
-
6
votes2
answers796
viewsHow to separate a string by commas, except when you have a space later
I have a string and I need to separate it into one array. However, the separator character needs to be the comma (,), but if you have a space right after (", ") she is preserved in separation. I’m…
-
6
votes2
answers236
viewsRemove unwanted characters from a List<string> without going through the list
Be the following excerpt a Windows Forms application. List<string> lista_strings = new List<string>(); for (int i = 0; i < 2000; i++) { lista_strings.Add("TST1234"); //preenchendo a…
-
6
votes3
answers2675
viewsIs it possible to include more than one variable per input in Python?
In C I can do it: printf("Informe 3 numeros'); scanf("%d%d%d", &a,&b,&c); Can I do a similar process in Python? I did some searches and found that I can do so: a,b,c = input('informe 3…
-
6
votes3
answers264
viewsReceive a string and put keys in it
I have a script that receives a string. I need to receive this string and add it to its key ends. I have a problem when placing: variavel = input('informe um valor') print(f'{variavel} aqui vem um…
-
6
votes1
answer196
viewsThe dollar ($) does not work to interpolate a string in Javascript
I’m using a code that uses the dollar sign ($) Javascript, only when using the cipher it gives error in the console and the code to fetch the data of an API ends up not working. What I need to do…
-
6
votes3
answers259
viewsWhich means an "!" exclamation before a string inside an if in C#
Hello, I have a question regarding some "snippets" of a program I am using to "study", the question is, what is the meaning of "!" inside an if before a string, I saw some topics on the site…
-
6
votes1
answer117
viewsCan I create function parameters like string?
I am trying to delve into functions and in the example of the site MDN Web Docs they have the following example: var math = { 'factit': function factorial(n) { console.log(n) if (n <= 1) { return…
-
6
votes3
answers303
viewsWhen I compare two strings to the "bigger" and "smaller" operators, what am I comparing?
var a = "a"; var b = "b"; if (a < b) // verdadeiro console.log(a + " é menor que " + b); else if (a > b) console.log(a + " é maior que " + b); else console.log(a + " e " + b + " são iguais.");…
-
6
votes4
answers3540
viewsHow to count occurrences of a letter in a sentence?
I’m trying to do an exercise whose goal is to know how many times a certain letter appears in the sentence, I was trying to do so: var frase = "o homem é o lobo do homem"; var letra = "o"; for (var…
-
6
votes1
answer99
viewsWhat are the differences between String.prototype.match and String.prototype.matchAll methods?
Historically, Javascript relies on the method String.prototype.match to perform, for example, string searches through a pattern via regular expression. However, starting with Ecmascript 2020,…
-
6
votes1
answer209
viewsWhy, when an iterator is not used, is an emoji "broken" into two parts?
Considering the code passage below: const str = 'Olá! '; str.split('').forEach((char) => console.log(char)); Note that all characters were separated from the string correctly. However, the emoji…
-
6
votes2
answers144
viewsHow does changing the prototype of the String.prototype.toString() method affect this code in Javascript?
I couldn’t understand why the method reverse is applied in the string "abcde" (over-written in toString) and not in "12345". String.prototype.reverse = function() { return…
javascript string characteristic-language objects prototypeasked 3 years, 10 months ago vncsbraga 61 -
6
votes2
answers229
viewsIf Python strings are immutable, how can we change them with the replace() method?
If Python strings are immutable, how can we change them with the method replace(), for example? Ex: s = "banana" s = s.replace("b", "z") print(s) # zanana Is this a change of the original string or…
-
6
votes3
answers146
viewsHow to use double quotes in a python application by running a subprocess
I’m trying to add a new wifi network via command line in a Raspberry Pi, however when I pass the string containing the data of the Wifi network the quotes that should be between the login name and…
-
5
votes2
answers4407
viewsIn SQL Server how to convert string uppercase part lowercase based on tab: ?
I need to make a script to convert all user records into a table in this format (single field): INFORMATICA\desenvolvedor ADMINISTRACAO\contador That is, before the uppercase bar and after the…
-
5
votes2
answers3054
viewsHow to use special characters in strings?
What are the characters for ~ and @ in the string of path in ASP.NET. Example: StreamReader srFile = new StreamReader(@"\\server\pasta\arquivo.html");…
-
5
votes2
answers131
viewsPick singularly characters in a multiple string
Hello, I need help with a regular expression that satisfies some occurrences of a text file. In this case, I need a regular expression that finds occurrences where there are a minimum number of…
-
5
votes3
answers860
viewsExtracting Numbers from a String
I have a string in the following format: 01 - 02 - 03 - 04 - 45 - 86 I need to put these numbers in one array int[6]. What is the best way to do this operation?…
-
5
votes2
answers710
viewsStatic string being created with wrong Encode
Hello, When creating a string in a Java class (for example: String t = "Ola Java!"), it seems that the compiler is choosing the 'wrong' encounter to interpret the bytes that are in the source and…
-
5
votes1
answer610
viewsHow to encode an array of bytes (string) in another database in order to represent the result with the characters of A-Z and 0-9 in Delphi?
I need to reduce the size of a string, but keep it in a predetermined character range. Use an encryption routine that the result returned by it is a hexadecimal character set, par a par,…
-
5
votes3
answers1796
viewsQuery in an SQL string in C#
I’m doing a query in the database via string sql.append, in the method call I have two parameters, two strings these receive one textbox typed by the user and check in the database. How do I…
-
5
votes1
answer230
viewsPHP says that two equal strings have different lengths
I want to compare two strings but something unusual happens. I have the code: <?php $char = 'Á'; var_dump('Á'); var_dump($char); The variable $char receives 'A' and the result is as follows.…
-
5
votes2
answers592
viewsHow to convert a Std::string to a Qstring?
I’m trying to make a simple dialog box display my name. See the code. Pessoa *p = new Pessoa("Ronald Araújo", "[email protected]", 23); QMessageBox msg;…
-
5
votes3
answers8755
viewsWhat is the best way to replace a character in a given String position?
I need to replace a character at a certain String position(). Example - Swap character[21] with 'X': String Original = 01078989469150999134B B 2116456 Modified String = 01078989469150999134B X…
-
5
votes1
answer723
viewsFind all instances of a pattern in a text
I need to write a program that identifies a lowercase letter surrounded by three uppercase letters on each side. For example: "AEIoSDE" == "o" I wrote the code as follows: # coding: utf-8 letra =…
-
5
votes2
answers172
viewsHow to use Reflection on a COM object?
I am trying to do a Reflection in a program, however, when the time to pick up the type of the object (Which is necessary for the Reflection) is returning "System. __Comobject", and this is not…
-
5
votes3
answers369
viewsStringbuffer.equals and String.equals difference in Java
The behaviour of the method equals class StringBuffer Java is different from equals class String? If yes, how would I overwrite that?…
-
5
votes1
answer20517
viewsCompare two strings in C
Hello, people, I want to compare two strings but the result is not returning what is expected, in this case the index in the function search_name, the error is in the fourth line of the function…
-
5
votes1
answer1381
viewsCount string characters
I am counting the characters of a string in PHP. The content of the string is: 10,12,12,22,33. I want to percolate to print one by one and with an " n". The problem is that I use strlen, and it…
-
5
votes2
answers6174
viewsHow to count the frequency of each letter in a string?
I need to count the relative frequency of each letter in a string (only letters), without considering the spaces, without differentiating between upper and lower case and without differentiating…
-
5
votes2
answers6555
viewsHow do I check if two strings are anagrams of each other?
I need to buy two strings and check if the second one is an anagram of the first one. I thought I’d use FOR repeat loops. I think you should first check if both are the same size, then go through…
-
5
votes1
answer9847
viewsHow to create string vectors in java?
"Make an algorithm to receive an integer n (number of students), an integer m (number of subjects), and nxm grades from 0 to 10, which each student obtained in each discipline. Present: a) which (or…
-
5
votes1
answer10937
viewsDifference between Ansistring, Widestring, Unicodestring, Shortstring and String and how to convert
During my Delphi learning I see implementations that use AnsiString,WideString, UnicodeString,ShortString and String but I don’t know the difference between them. Another thing that always occurs to…