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
-
5
votes2
answers116
viewsHow to make readable the code that uses String properties?
I have a string that uses parts of another string, how to make this code more "clean"? Since it is very difficult to understand. String sessionHash = dirPath.substring(dirPath.substring(0,…
-
5
votes3
answers1828
viewsFormat Strings to RG
How can I format this String: 12345678x for this: 12,345,678-X ? I tried to use the String.Format but I couldn’t. Solved: public string RgFormat(object rg) { string strRg = rg.ToString(); return…
-
5
votes2
answers6374
viewsString comparison
There are several ways of comparison, but I always see that the most suitable are (===, strcmp ou strcasecmp). Among these forms presented considered the safest (according to some websites on the…
-
5
votes2
answers114
viewsHow to get a Date String?
My question is how to get a string and manipulate it. The user will inform dd/mm/yyyy in the form of String. How do I make this catch? And then I need to make this date whole so that I can do the…
-
5
votes1
answer2701
viewsJavascript: how to count the characters of an html text?
The problem: I have formatted html text and I need to count how many characters (ringtones for journalists) I have. I will use Javascript. Some solutions came to mind, but as this will be done…
-
5
votes3
answers1630
viewsMount a single string with multiple strings from a Java Arraylist
How can I take several Strings of an Arraylist in a simplified way and join in only one String type variable? I’m new to Java and I’m having difficulty completing this change in a simplified way,…
-
5
votes1
answer149
viewsChecking string inside string
How to know if a specific text is contained in a string? example: String str = " Hello Word"; How do I check if the word "Hello" is contained in that string "str". And if the check is true, how do…
-
5
votes1
answer1820
viewsHow to convert string to double without rounding error?
Because the following command: Convert.ToDouble("199998,99") Results in: 199998.98999999 Already the command: Convert.ToDouble("199998,98") Results in: 199998.98000000001 ?…
-
5
votes3
answers1590
viewsHow to add or subtract a digit in the Textbox via a button?
I want to add to a number in a TextBox generating a digit when the user clicks the " + " button and subtracts when he clicks the " - ". For example: the random number was 2. If I click on +, 3…
-
5
votes2
answers887
viewsCalling a string equivalent method
Consider the following class: public class AnimationManager : MonoBehaviour { public GameObject[] Enemies; void OnTriggerEnter2D (Collider2D o) { if (o.tag == "Player") foreach(GameObject Enemy in…
-
5
votes1
answer544
viewsEncryption using java stacks
In an encrypted message using stack to invert each word of a String and using the chatAt(int) to pick up specific characters from it, I had the following problem, when placing a character on the…
-
5
votes2
answers182
viewspreg_split is not breaking the strings in the array
I’m not getting to use the function preg_split() correctly. I’m trying to break a string array() via regex but it’s not happening. $string = "<:termo.9:><:termo.10:><:termo.11:>";…
-
5
votes1
answer995
viewsAdding a comma to a string
Good personal and possible to add comma in an example string: a = '1234567890abcdefghijklmnopqrstuvwxyz_' for her to stay like this a = 1,2,3,4,5,6,7....…
-
5
votes3
answers94
viewsHow to stick with just one part of the string?
I have several string’s (idPergunta-18, idResposta-18, idPergunta-17, idResposta-17) Needed to write only (idPergunta, idResposta, idPergunta, idResposta) How do I in PHP? The goal is as follows:…
-
5
votes1
answer615
viewsWhat does the term "String... string" mean in java?
What the term means String... string in Java? And how to elaborate a method that returns a String... as an example: public String... getStrings(){ return String... s;) } I know it’s not like that,…
-
5
votes3
answers5080
viewsClear C buffer with fflush() or __fpurge()
Studying strings in C I came across the following phrase: "Clearing the buffer, for example, is not always desirable, and for more professional and secure programming it is not recommended to use…
-
5
votes2
answers10981
viewsConcatenate char variable text in printf
I need to concatenate the name of the person (variable) with a text. Following the logic, it would look like this #include <stdio.h> int main (void){ char nome[6]; printf("Ola! Insira seu…
-
5
votes3
answers10165
viewsRemove non-numeric characters from a string
Example: I have the following string "M1245D454" and I need to just leave the numbers on it. M and D are examples, I want to remove any non-numeric character. There is some function in C# or VB.NET…
-
5
votes1
answer709
viewsWhy is strcpy() insecure?
I’m reading about secure programming, and I read that function strcpy(), of the C language, is an example of insecure. I also read that there is a secure version of this function, which would be the…
-
5
votes4
answers16290
viewsHow to remove spaces from a string in C?
I want to remove the spaces of a string, example: Pedro Henrique Ribeiro Would be: Pedrohenriqueribeiro The code I made, it takes away the space, but it duplicates a letter: #include…
-
5
votes2
answers109
viewsStore values in Hashtable
When I keep the value of this Hastable he makes me wrong. Follows the code: Hashtable ht = new Hashtable(); ht.Add("index", index); ht.Add("tipo", "1"); string tipo = ht["tipo"];…
-
5
votes1
answer446
viewsClang has Character error Too large but Visual Studio builds normal
I’m having a hard time understanding why the Clang presents the error message Character Too large for enclosing Character literal type when trying to execute the code: char c = 'ç'; while Visual…
-
5
votes4
answers602
viewsHow can I replace "String.isEmpty()" in Java?
I got the following: data = new Json().execute(URL).get(); System.out.println(data); if (!data.isEmpty()) { //erro neste data.isEmpty I have a mistake: has an error: Call requires API level 9…
-
5
votes1
answer6021
viewsHow to concatenate two strings?
Supposing I have two strings, Olá and mundo!, as I grant them using R?
-
5
votes5
answers29254
viewsHow to convert date to dd/MM/yyyy format?
After I published my app, I started to receive the dates in the American format like this:9/14/2016 12:00:00 AM How to format to dd/MM/yyyy? I tried to convert.ToDateTime() more does not work.…
-
5
votes1
answer4176
viewsAlignment with string.format and Unicode
I’m having trouble with the alignment of strings when using the .format(), for example when doing: >>> print '{:>6}'.format('agua'} agua >>> print '{:>6}'.format('água'} água…
-
5
votes1
answer716
viewsWhat is the difference between the "+" and "&" operators when concatenating strings?
In VB.NET, there are two operators I use in concatenating strings, the & and the + (I know there are more efficient methods for concatenating strings, but in this question, I pay attention only…
-
5
votes1
answer821
viewsReduce a string in C language
How do I reduce the size of a string in C? In my program it is implemented as follows: char nomeString[] = "nomedoarquivo.txt"; I intend to cut the ". txt" of the end of the string.…
-
5
votes2
answers728
viewsHow to separate numbers from three to three, backwards, in Javascript, without regular expression?
I already know how separate the numbers from three to three, backwards, with regular expression in Javascript. But I wonder if in Javascript there is a simpler solution, and without the use of…
-
5
votes2
answers252
views -
5
votes5
answers29639
viewsHow to convert an int number to string in python?
I need to do an exercise where I input an integer variable of 3 digits and the python has to show it reversed, but up to where I know an integer variable n can do this, but a string can. What can I…
-
5
votes2
answers1728
viewsHow to receive a string and switch to check in C?
I have to develop an algorithm that gets the name of a place, for example, "School", and based on this, do a check of the string in the switch, and if it is "School", then it sends a message to the…
-
5
votes2
answers961
viewsHow to convert string (in English) to date?
I have a data.frame with a column (mes) that represents the month and year of each observation that is in string form. I wanted to modify it to date so I could use proc in excel with date. How can I…
-
5
votes3
answers8939
viewsWhat is the correct way to declare a string in C?
There are several ways to declare a type variable string in C as: char *str; char str[]; char str[100]; char str[1][100]; What I’d like to know is, is, is there a correct way to declare a variable…
-
5
votes3
answers1309
viewsI want to change a string in 3 positions
I would like to walk 3 positions with a letter of a string, for example, make the letter A turn D, I tried the second command: texto[c] = texto[c] + 3 But it still doesn’t work, what would be the…
-
5
votes2
answers340
viewsHow to create an array whose indices are characters from an informed string?
I wanted to create a vector in java in which each input of the vector was a character of a string that I informed public static void main(String[] args) { String[] words = {"java"};…
-
5
votes2
answers238
viewsHow to find reserved word in a sentence?
I am creating a routine to search reserved words in a text (name of people). I have tested with Contains() and IndexOf(). Works well most of the time. However in some words the return does not…
-
5
votes2
answers1259
viewsWhat are the function of each string prefix in Python?
In Python, we often see strings with a prefix, such as below, where the prefix is used r: r"""OS routines for NT or Posix depending on what system we're on. This exports: - all functions from posix…
-
5
votes2
answers487
viewsString Sweep in Search of Substrings Ignoring Accent and Case and For Each Match Perform an Action
I need to search in a string a specific substring and for each occurrence found, I must execute an action to replace what was written by the version in bold, as it appears in the list, ignoring…
-
5
votes2
answers134
viewsWhat is the problem of returning a local variable?
What can happen if I return a local variable? I read on the internet that it is not a good idea to return a local variable. Maybe why the variable when exiting the function is deleted? Example:…
-
5
votes1
answer219
viewsIs it incorrect (or problematic) to create a string array struct?
I’m not sure what’s the ideal way to create a structure (struct) that contains a array of string, in case I have a structure like this: #include <stdio.h> #include <stdlib.h> typedef…
-
5
votes1
answer848
viewsHow to calculate the percentage difference (or similarity) between two strings?
I’m using PHP in an application I’m developing, where I have a text editor. In this text editor, with each change made, before saving, I create a record with the original data (i.e., how they are…
-
5
votes1
answer1426
viewsWhat is the . isidentifier() method used in Python?
I came across the method string .isidentifier() and also the .isprintable(). Why use them? On what occasions would I wear this?
-
5
votes2
answers5954
viewsWhat is the difference between using toString() and JSON.stringify()?
var arr = [1,2,3]; arr.toString(); // "1,2,3" JSON.stringify(arr); // "[1,2,3]"
-
5
votes3
answers349
viewsWhat are the advantages of using PHP’s sprintf function?
I can see an advantage in using the function sprintf in place of concatenation: readability. In addition to readability, what are the other advantages of sprintf() in relation to concatenation? Is…
-
5
votes1
answer57
viewsPHP xf0 represents 0xF0?
If \xF0 represents a hexa as well as 0xF0, because their exit is different? echo "\xF0"; echo 0xF0; I can’t really find any information on that notation \xF0 in the PHP manual.…
-
5
votes2
answers2226
viewsSwitch string to high box and remove blanks
I’m trying to make a program in Python 3 that should turn the typed text into upper box and remove blanks. I would like to know what is wrong with my code since it is not eliminating the whitespace.…
-
5
votes2
answers120
viewsHow to use C#quotes?
I’m starting to program in C# and I’m feeling some difficulty with quotation marks when I need to paste some text. In Python I could use the triple quotes to paste some text that there was line…
-
5
votes1
answer123
viewsWhy is it possible to store a string on a char pointer?
Why char stores a single character and the pointer points to its value in memory, so it shouldn’t have just one character? Example: char *str = "Ola"; Why str does not store only one character?…
-
5
votes2
answers201
viewsWhat is the difference between the string.Slice() method and the string.substring() method?
We know the method string.slice() and the method string.substring() allow extracting a part of a string and creating a new string as a result (without modifying the original string). What…