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
-
3
votes2
answers1554
viewsHow to clear the array name so it doesn’t end up with the rest of the previous strings
#include <iostream> #include <string.h> using namespace std; int main() { int condicao; cin >> condicao; //Determina o tamanho do vetor…
-
3
votes3
answers4536
viewsHow to select a piece of the Java string?
I have the String x = "@646646&". I’d like to take everything in between @ and & and play in another String. Regardless of what is between these characters being number or not. How do I do?…
-
3
votes2
answers798
viewspython - Delete string end characters
Is there any way to delete characters at the end of a string in python? For example: a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" B = "ABCDEFGH" I need string "a" to be the same size as "b," so that’s possible?…
-
3
votes2
answers7052
viewsHow to count occurrences of a substring in a Python string?
How do I read two strings and check the number of occurrences of the second string in the first? Example: If the first string typed is "abracadabra" and the second "bra", then the number of…
-
3
votes3
answers16319
viewsConvert from string to list?
I needed to pass a string of the kind: 0.4350 0.8798 0.0099 1 for a list [0.4350, 0.8798, 0.0099, 1] with a script simple. How can I do it?…
-
3
votes2
answers205
viewsWhy do some functions that work with C strings start with *?
In one of our classes we were taught that when a function receives as a parameter an array it is actually receiving the memory position in which it is allocated so it is not necessary to return any…
-
3
votes1
answer70
viewsUse of % in variables
I can not understand what this symbol serves in a variable, I see its use in some points in codes in SQL, Shell Script, C. For what it serves? For example a use of this symbol in Shel Script:…
-
3
votes1
answer408
viewsHow to extract space-separated words via Javascript
Continuing the marathon of articles regarding the extraction of texts, I noticed that this type of question is very difficult to find next to a clear and direct answer. In order to remove my doubt…
-
3
votes1
answer115
viewsWhy does Shortstring consume more memory than an ordinary String?
I made an example here to see how much memory consumes each variable and noticed that a variable of type ShortString consumes 256 while a variable of type String consumes only 4. Following example…
-
3
votes3
answers1491
viewsHow to replace the number of letters of a word with a character?
I’m doing a hangman’s game, let’s suppose I type the name "john" into a box of text, then I press a button and I want the "text 2" box to have "_ _ _", so I want the same number of underscore that…
-
3
votes3
answers1314
viewsFormat Field C#
I know the 'N' and 'C' formatting of C#, but they do not suit me. I get 1000 database and would like you to format to 1.000. What I put in the .ToString("???")…
-
3
votes3
answers36
viewsString handling at alternate positions
I have an output that via EXPECT access an equipment and receive the data below: $result1 = " =============================================================================== Service Basic…
-
3
votes2
answers1008
viewsWhat is " x" in the Python strings?
I replied a question here on the site where there was the following string in the Python language:…
-
3
votes1
answer3224
viewsInput string was not in a correct format
When calling the method below comes the message the input character string was not in a correct format private void SubmitData() { try { string user = usuario.Text; string pass = senha.Text;…
-
3
votes1
answer4847
viewsHow do I put the value of a variable inside a textbox?
Guys I’m having a boring problem. I wanted to put the text I took out of a textbox and put in another that this defined as readonly. I wanted it to work as a label. I tried textchange gave error.…
-
3
votes1
answer634
viewsHow do I let the string size be set by scanf()?
My question is about the theory. I know it’s possible to make a string without limiting the size of the: char teste[] = "Teste"; however, I would like to know if it has how to do the same thing, ie…
-
3
votes2
answers880
viewsC# - How to check if a string has only spaces?
The propgram reads all lines of a file, and I have to check if in this line that he is reading there are only spaces, because if there are only spaces in it, it will be considered invalid by the…
-
3
votes2
answers259
viewsOptimization of multiple ifs into something more practical
I have a string alphabetical: char string[] = "aouihuiahsudasduihqmdoiqjnduiamsdoqnwuidamodkjwodkaposdj"; I want to go through it all and for every character of it, say how many times it repeats in…
-
3
votes1
answer2087
viewsWhat is the difference between "string" and "Character" in Python?
What is the difference between the string and Character? For example: print 'Olá, mundo!' print "Olá, mundo!" Since the two in theory are the same thing, right? PS.: I opened XML to do my color…
-
3
votes1
answer1613
viewsFind String in Arraylist
ArrayList<String> posicoes = new ArrayList<String>(); posicoes.add("Ricardo;01051509912;gmail"); posicoes.add("Renato;123456789123;hotmail"); posicoes.add("Rodrigo;09873923121;yahoo"); I…
-
3
votes1
answer569
viewsUninitialized variable used in this function?
After compiling the program, you receive 2 warnings of the same type: "Warning: 'phrase' is used uninitialized in this Function" and "Warning: 'word' is used uninitialized in this Function"…
-
3
votes1
answer403
viewsHow to get the same strcpy() result with strcpy_s()?
I downloaded a C++ code from the internet and when I open the solution, the following error: Error C4996 'strcpy': This Function or variable may be unsafe. Consider using strcpy_s Instead. To…
-
3
votes5
answers7921
viewsHow to properly format CPF in Python?
I have the following code: test = input ("CPF: ") When the typed CPF gets: 12345678900 But when I return this input he comes back: 123.456.789-00 How do I do it in Python?…
-
3
votes0
answers75
viewsWhat is the difference of declaring these strings in Python?
Is there any difference between a string declared with single quotes ' a = 'Special cases aren\'t special enough to break the rules.' and one with double quotes " b = "Special cases aren't special…
-
3
votes1
answer372
viewsDelete equal values within a dynamic array
I have an array with several dynamic names that can change each time, what is the most correct way to go through this array and create a condition to delete them iguail? (in the case of two items…
-
3
votes1
answer89
viewsRecover accents of a string with PHP
I am using friendly urls and to generate the link, I am using this way: $string = $jm->NomeCategoria; // retorna roupa de verão $hifen = preg_replace('/[ -]+/' , '-' , $string); // incluo o hífen…
-
3
votes2
answers423
viewsIdentify string between two known snippets in a string
I would like you to help me on the following: Given this CGC UUC GCU UUG GAA AAU UUG UGU GUU UUU UGU GGC UGC UCG CUG CUC AAA UUG UUC GCU GCU UUU UGU GUC CUG GCU GCU UUU AUU AUU UUA CGC UGC UUG GCG…
-
3
votes2
answers797
viewsWhy can you pass a char vector to the scanf as the direct address or variable?
If the name of the vector or matrix is already the address of the first element, why scanf(), using the primitive types (int, char, float, double) I need to pass the address, being that when we want…
-
3
votes1
answer509
viewsTake values separated by spaces in C#?
I want to take the values, for example, 79 201 304 and store in one vector each number at one position. Example : int array[0] = 79; int array[1] = 201; int array[2] = 304; public static int…
-
3
votes3
answers142
viewsIs there any way to get a particular line from a string?
I have this example string: s = [[Pão com Requeijão]] Is there any way to get only the second line of the string? If so, how?
-
3
votes1
answer49
viewsstring transformation in R
I wonder if I can turn an observation of a variable, which has a string shape, into uppercase letters. for example: #como esta: x=c("Casa branca","Barco Azul","casa preta") > x [1] "Casa branca"…
-
3
votes2
answers3545
viewsHow to print the percentage sign in Python 2/3?
How do I use % after a markup? Ex: print("%d texto texto 10% texto"%var_a)
-
3
votes1
answer82
viewsHow to improve this code
A few days ago I asked for help here in the OS to parse JSON in Java and I got what I wanted, however, I had to do a "gambiarra" by not knowing a better way. It’s working, but I’m sure the code can…
-
3
votes1
answer142
viewsPerformance Itextsharp
I’m doing the reports using iTextsharp and the result has been acceptable, but working with many records has become slow. Currently I do so: I capture the database data (storing in a DataTable); In…
-
3
votes1
answer84
viewsWhat is the fastest way to build text?
I have a large text (1000 lines) with formatting. Briefly (not this text but I will use an example) I have 2 ways to build it: StringBuilder sb = new StringBuilder(); sb.append("oi" + "meu nome" +…
-
3
votes2
answers576
viewsExtract Date from a C#String
I need to extract two dates from a string that comes in the following format: string teste = "Aprovados por autorizantes da aplicação -> 02/03/2018 à > 02/03/2019"; This is the start date and…
-
3
votes3
answers2037
viewsRegex to validate certain date format
I was modifying a regex for a program in c++ that would validate the following date input form 29/feb/2000. Currently she was only accepting 29/02/2000 or 30/03/2017. I tried to add for the other…
-
3
votes1
answer821
viewsTake numbers together the letter with str_replace
I am wanting to take a part of a string, more specifically numbers together with the letter, for example: $string = "Parte da string - 60h" Well, I use str_replace as follows: $string =…
-
3
votes1
answer348
viewsHow to print the binary representation of a character?
I am in need of obtaining binary representation of the characters of a string. I can do the hexadecimal representation with own printf using %x. Something like: void imprime_hex(char *input) {…
-
3
votes2
answers866
viewsCompare using String.Contains() disregarding accents and case
I know there’s already question, I even used the same title to call attention, but this one refers to C#, I’m having this problem in java, code: //historico e searchC são ArrayLists, no caso do case…
-
3
votes2
answers3768
viewsWhat is the equivalent of PHP explode in Python?
In PHP, if I want to split a string into several parts based on a delimiter, I use explode. How can I do the same in Python?
-
3
votes2
answers38
viewsGenerate a string that contains only the numbers of another string in php
I made the following function in php that takes a string, and returns a new string containing only the numbers of the received string. I’m just not able to concatenate each number to this new…
-
3
votes1
answer96
viewsLexicographically compute the letter of a string
My function needs to lexicographically calculate the value of the characters (by the ASCII table) of the string. For example: "Alibaba" and "Came"'A' = 65 and 'V' = 8665 - 86 = -21. Then the…
-
3
votes1
answer68
viewsError in Lexing a Mathematical Equation
I’m doing a C++ equation interpreter and I’m trying to show the type of the symbol. But I’m in trouble. I don’t know what’s wrong. Any constructive tips are welcome. main.cpp: #include…
-
3
votes2
answers2791
viewsHow to turn a character into an integer in C?
How to turn a character into an integer? #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char N[11]; int i; scanf("%s",N); int cont = strlen(N);…
-
3
votes1
answer104
viewsHow to print 0.10 instead of 0.1 in Java?
The code below counts how many letters there are in a word and multiplies by 0.01. The problem is that I want when a 10 letter word, for example, is typed, to have an output of 0.10 and not 0.1.…
-
3
votes1
answer54
viewsIs it possible to interpolate a string already declared in C#?
The question What does the symbol "$" mean before a string? , explains that it is possible to interpolate strings in C# through the $ (dollar sign). However, I noticed that, in all cases where it is…
-
3
votes1
answer464
viewsHow to Replace Bar and Space by Dot and Comma in C#
I want to create a system that removes all bars and spaces per point and comma, for example 4587 / 5458 = 4587;5458 4587 5458 = 4587;5458 How can I create this system with C#? My code so far is like…
-
3
votes1
answer106
viewsc# - Error trying to Replace a string
Boa Pessoal, I have the following problem: While trying to do the replace of a string (of a Literal Control), using the code below, the value of the code is not changed.…
-
3
votes1
answer64
viewsIs there a function that searches if a word exists in the text?
In PHP there is some função checking words in text, example: A camila morreu de diabete. I want to create a function looking for the word morreu, for after they find playing in a if the result,…