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
-
13
votes3
answers4221
viewsTake only the values before the character "=" using regular expression?
I have a file containing the following contents: Maringa=123123 Marialva=789789 Mandaguacu=123456 Cidadex=A341a2 How do I pick up only the characters before the =, using regular expression? I tried…
-
13
votes2
answers1894
viewsHow to align strings to use in a listview?
In my Android project I need to create a table with a listview but the data always comes misaligned. I place each record of my database in a position of a string array to use it in listview. The…
-
13
votes3
answers2226
viewsPerformance: string "concatenated" or all in the same line?
I have a loop with thousands of results that renders a table. The string is mounted through Stringbuilder in this way (sample snippet): ScriptTbody.AppendLine("</select>");…
-
13
votes3
answers759
viewsComparison between a numeric string and an alphanumeric string
The following operation returns true: var_dump("1" == "1e0"); //1 == 1 -> true But if I add an "e" at the end of the second string, it already returns false: var_dump("1" == "1e0e"); //1 == 1…
-
13
votes3
answers8700
viewsTypeerror: not all Arguments converted During string formatting (Python 3.4)
I’m new to programming and I’m trying to do a simple code for an exercise to calculate a phone bill: t = float(input('Digite a quantidade de minutos gasta: ')) if t < 200: p = t * 0,2 if t >=…
-
13
votes3
answers1482
viewsWhy does Visual Studio suggest simplifying names? - IDE0001 Name can be simplified
Visual Studio 2013 suggests name simplifications, as you can see below: The suggestion is: IDE0001 Name can be simplified Translation : IDE0001 Name can be simplicate Example: var obj = new…
c# string visual-studio-2013 visual-studio encoding-styleasked 9 years, 3 months ago Guilherme de Jesus Santos 6,566 -
13
votes1
answer718
viewsWhy should I use the Stringbuilder class instead of the String class?
Why these two classes are different, because it seems to me that they could be one class. For example, the method Append, it seems to me that he does the same thing as the operator +.…
-
13
votes2
answers1019
viewsConvert.Tostring() and . Tostring()
Is there any glaring difference between them? Whether in performance or ways of dealing, what are their particularities? What would be the correct way to use (if there is any difference)?
-
13
votes3
answers1511
viewsHow can I replace a part of a string by itself plus the "~" character?
How can I replace a part of a string by itself plus the character "~"? I’m doing it this way: only when the string has two equal numbers as the 51 that comes just after AP and the contained in the…
-
13
votes4
answers320
viewsWhat is .= in php?
What is .= in PHP? I’m wondering if it’s a concatenation or multiplication.
-
13
votes4
answers21920
viewsHow to transform string into character array?
It is possible to transform string into character array? I only found it with the method .split(param); I’d like to convert a string in a array of characters, one character in each index. I would…
-
13
votes3
answers9451
viewsWhat is the meaning of the sign || '-' || in SQL
I am performing a query in an Oracle database and come across this symbology || '-' ||, in my query. I’d like to know the meaning? Select xf0cdloc || '-' || XN4CDEMP AS LOCOMOTIVA, From Trem…
-
13
votes5
answers453
viewsHow to separate "words" in Camelcase in C#?
How can I separate "words" into Camelcase using hyphen for example? String: string example = "CamelCase"; // CamelCase para: // Camel-Case and enumerator: enum Example { CamelCase }…
-
12
votes4
answers6231
viewsHow to select a text snippet in a String?
I’m creating a text file and using some delimiters (<# and #>) I need to select what’s inside the delimiter <# texto.delimitado #>. Using the function split() javascript. What would be…
-
12
votes2
answers372
viewsHow to create regexReplace for a delimiter?
I have the following content: 123|321|1234\|56\|teste\||123 I’d like to make a regex replace to replace all | by line break and ignore the | escaped with \, this way I would like to get the…
-
12
votes1
answer100
viewsHow to define Titlecase using regex in Javascript?
I have this Function: var titleCase = function(s) { return s.replace(/(\w)(\w*)/g, function(g0, g1, g2) { return g1.toUpperCase() + g2.toLowerCase(); }); } If I call her by passing something she…
-
12
votes3
answers3072
viewsHow to convert a string to List<int>
I have the following variable and would like to convert it to an integer list: string variavel = "1,2,3"; How to convert it to a list of integers?
-
12
votes2
answers322
viewsComparison of search algorithms within text strings
I am trying to implement the following algorithms for searching expressions within Java text strings: Knuth-Morris-Pratt (KMP), Brute Force, Boyer-Moore and Levenshtein How could show the similarity…
-
12
votes3
answers14451
viewsTurn the first letter of a string into uppercase?
Example: I have a string "stack exchange", how do I transform your first character, getting "Stack exchange"?
-
12
votes2
answers3131
viewsHow can I turn line breaking into <br /> in Javascript?
In PHP, we can convert a line break to a <br/> through function nl2br. What about Javascript? How can I do this safely? I decided to ask the question because I don’t know if a simple…
-
12
votes4
answers595
viewsHow to create a variable where to access its properties via string?
I’d like to access by string the properties of an object: (EXAMPLE 1) var cor = casa["cor"]; var tamanho = casa["tamanho"]; Instead of accessing like this: (EXAMPLE 2) var cor = casa.cor; var…
-
12
votes2
answers10649
viewsCheck if a word is within a sentence
There is how I check if a word is within a phrase described by the user? Ex: palavra = "criativo"; Phrase written by the user: "Eu sou criativo"…
-
12
votes2
answers720
viewsWhat Means Two Keys in Javascript
I understood the "===" that tests value and type, different from the "==" that tests only value, but I didn’t understand the double key, type: {{alguma_coisa}}, for example in a Javascript that I…
-
12
votes2
answers52864
viewsHow to check if the Term is contained in String in PHP?
I need to check if a certain tag is inside the string. I get this string from the database that comes in the form of tags comma separated without spaces as below: String canais,proteses,implantes…
-
12
votes3
answers5129
viewsWhat is the difference between using single and double quotes in C#?
In PHP, when we use single quotes or double quotes, both forms have the functionality to declare a string. There is only one small difference. I am now starting a study with C#. When I went to try…
-
12
votes3
answers1093
viewsHow to check if at the end of String is one or zero?
How can I check whether at the end of a string is 0? The problem with this code is that the string may contain: jrp_documento.jrp_doc_001fornecedor|0 My need is to check if at the end of the string…
-
12
votes3
answers5507
viewsCount how many elements are duplicated in a string
The purpose is to account for the number of elements that are repeated in a string and not just check for duplicates or count how many times these elements appear. For example: "aabbca1m" // 2 (a,b)…
-
11
votes2
answers3208
viewsDifferences and use of Strings vs. Charsequence
Many methods in Java expect parameters CharSequence, but the code runs normally when I pass a String without conversion, for example: String mensagem = intent.getStringExtra(MainActivity.MENSAGEM);…
-
11
votes4
answers15696
viewsHow to extract digits from a Python string and add them together?
I need to decompose one string in Python, separating letter and numbers, and summing these numbers. For example: string = "96h11k" Of that string need to extract the numbers 9, 6, 1, 1 and add them:…
-
11
votes1
answer58531
viewsRemove accents from a php string
I’m having problems with the accents in my code and I wanted to remove the accents when they did the research, Ex: Search: Hello | Hello. When doing a Music search on the site it returns the url…
-
11
votes2
answers1824
viewsIs there a difference between strtr and str_replace?
I was analyzing the way functions behave strtr and str_replace And I noticed that, at first glance, they both seem to do exactly the same thing. Example: $translators = [ 'da hora' => 'bacana',…
-
11
votes1
answer27744
viewsConcatenate Strings into Java Loops - Stringbuilder or '+'?
Java allows us to concatenate Strings in Java using only the operator '+' String str = "a" + "b" + "c"; It’s a simple way to do the job, and much less verbose than with Stringbuilder. But in cases…
-
11
votes2
answers335
viewsSplit a String dynamically based on screen size
I’m working on an android app and at some point I get a string from a web-service that is quite large, and the client wants this String (which will be shown in a Edittext) be divided into multiple…
-
11
votes3
answers25171
viewsHow to write multiple lines in Python?
How can I write a string with multiple lines in Python? As I come from PHP, I usually do so: $string = " uma linha outra linha2 " Or else: $string = <<<EOT uma linha outra linha EOT; When I…
-
11
votes2
answers1506
viewsWhat is the difference between assigning and comparing string variables with function or with assignment and comparison operator?
I came across the following questions: What is the difference between expressions strcpy (s, t) e s = t ? What is the difference between expressions if (strcmp (s, t) < 0) e if (s < t) ? I…
-
11
votes2
answers70082
viewsHow to concatenate multiple Strings in Python?
The following method c.filtraNome(nome) carry out a consultation at the bank (sqlite3), however, I don’t know how I can group each field and return the already formatted query in the following way:…
-
11
votes2
answers6808
viewsWhat is the difference between Carriage Return and line feed?
There are two different ways to break a CR line (Carriage Return) and LF (line feed). What is the difference between these two? When should one or the other be used? Depends on the system? Language?…
-
11
votes4
answers25519
viewsThe input character string was not in an incorrect format. Operators
Hello, I’m beginner in programming and I’m trying to show the user how much RAM is being consumed at the moment, I’m using the following code that is not pointing nor an error when compiling only…
-
11
votes4
answers160
viewsHow can I make a string code work with > or <?
Apparently I’m having problems with strings: public partial class Form1 : Form { private int _adicionar; private int _retirar; public Form1() { InitializeComponent(); } private void…
-
11
votes1
answer165
viewsLike, when and why use "Securestring" in C#?
I once heard about the class SecureString from C# and it seemed interesting to me, so I think it’s interesting content that can yield good answers from more experienced professionals. Some questions…
-
11
votes1
answer1208
viewsWhy String objects are immutable?
Up to the latest stable version, Java 8, type objects String are immutable. That is, any change in a String causes the creation of a new object String. This is not harmful from a performance point…
-
11
votes2
answers502
viewsWhat is the difference between "String(1)" and "new String(1)" in Javascript?
Why in Javascript it is possible to call String as a function and also instantiating? Take the example: var str1 = new String(1) var str2 = String(1) console.log("Valor é %s e o tipo é %s", str1,…
-
11
votes3
answers2425
viewsWhy in Java is the size of an array an attribute and a String and a method?
In Java, the size of a array of any object can be obtained with length, which would be an attribute. But in the case of String is length(), a method. However, if you have a array of String, uses…
-
11
votes6
answers1056
viewsHow to make a Split for when there is a letter in the string?
I’d like to make one string be divided with the .Split() every time there was a letter. Example: To string: 97A96D112A109X115T114H122D118Y128 Would become a array with 9 values: { 97 96 112 109 115…
-
11
votes1
answer1637
viewsNumber in full for number
I would like to transform an extended number to normal int; example: FunçãoParaConverter("trinta e dois") // retorna 32 FunçãoParaConverter("mil vinte e quatro") // retorna 1024…
-
11
votes4
answers455
viewsWhat is the difference between parseint() and operator + before a string?
I saw a colleague convert a string to integer using the syntax var a = +"10" but I always used the parseInt() and the line is usually like this var a = parseInt("10"). Why when placing the operator…
javascript string performance operators type-conversionasked 6 years, 1 month ago Hiago Souza 5,837 -
11
votes1
answer1878
viewsHow does String.prototype.normalize work in Javascript?
I was reading a reply here on the site and I came across the method String.prototype.normalize in the second example of code passed. I had already come across this method in another situation, but…
-
10
votes2
answers3444
viewsHow to count the amount of occurrence of a substring within a string?
I have the following return: EXCEPTION,Classexception,EXCEPTION, I’d like to take the amount of times that String appears EXCEPTION using Regex. I used the following code:…
-
10
votes4
answers13342
viewsMultiple lines of text or code with method ". html()"
When using the jQuery method .html() to apply multiple lines of text or HTML code to an element, the same error: Example in Jsfiddle $(function(){ $( '.qualquerClasse' ).html( ' conteúdo de 3 linhas…
-
10
votes1
answer3615
viewsGenerate list of possible combinations
We have 4 teams: Time 1 | Time 2 | Time 3 | Time 4 I would like to know how to automatically build a list of possible combinations of games between these teams. Example: Time 1 x Time 2 | Time 1 x…