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
votes1
answer334
viewsRaw String Literals Java
I saw that in JDK 12 it is possible to make raw string literals similar to some programming languages like C#, JS, R etc. Ex in C#: "Essa não é uma \n raw string"; Exit: Essa não é uma raw string…
-
5
votes4
answers5739
viewsHow to separate the letters of a string that are inserted into a list and place them in an array?
I have a list with the word "test", arranged in such a way: ['teste','teste','teste','teste','teste'] I would like to turn this list into a matrix, in which the letters are separated from each…
-
5
votes1
answer79
viewsHow do I get a value from a cell in R?
I imported my data that was in a spreadsheet from Excel to the R, by placing them in a variable called umParticipante. However, when I make the following code: umParticipante.nome <-…
-
5
votes2
answers389
viewsWhat is the function of the keys { } in this interpolation?
class MyStateFull extends StatefulWidget{ MyStateFull(this.nome); final String nome = 'Maria'; @override _ContadorClique createState() => _ContadorClique(); // @override //…
-
5
votes4
answers130
viewsString Manipulation in Javascript?
I have the following code var wcalcAlm = ('0140') alert(wcalcAlm) //retorno esperado ('01:40') I need that after the 2 position of the variable wcalcAlm be included :, thus having the following…
-
5
votes4
answers319
viewsRegex - set 2 limits and pick up all content inside
In the string below, I need to get the text content from ENERGIA ELETRICA CONSUMO up to the percentage symbol %. That is to say: ENERGIA ELETRICA CONSUMO kWh 370 0,787324 291,31 291,31 29,00% Is it…
-
5
votes4
answers1335
viewsHow to use . replace() to remove Python strings
I’m doing a Coursera exercise in Python. In this exercise he asks to build a Python function that takes a string (word) and removes the punctuation symbols. It provides me a list of strings ["'",…
-
5
votes2
answers441
viewsCheck if a string belongs to a list
This program is only printing that the letter entered by the user is a consonant, even when it is a vowel. I think it has to do with the in and not in, but I’m not sure. mensagem= list (input…
-
5
votes2
answers156
viewsWhat is the correct way to do an Replace in a string-like variable?
I need to create a folder on the file server and realized that the variable that receives one of the information is coming with invalid characters ( / : * ? " < > |) for creating a folder on…
-
5
votes2
answers1699
viewsHow to compare each character of a Java String?
I’m creating a Java application where I travel through one String with a bow for and I need to check every character of that String. Example: for (int i = 0; i < texto.length(); i++) { char…
-
5
votes2
answers260
viewsIn Python, how do you remove specific characters from all the records of just one particular column?
I’m at Jupyter Notebook working with Python. The dataframe has some columns, but in a specific column I want to delete all records that end with ". txt", meaning the last 4 characters. Image of the…
-
5
votes2
answers81
viewsCompare two lists without interference of upper and lower case letters
I want to develop a log-in system where it does not allow new users to have the same names already used by other registered users, but I’m having a problem in case of upper and lower case letters…
-
5
votes1
answer91
viewsWhat is Regexp Match Indices?
I recently found this package, which serves as a polyfill for a new Javascript feature. The proposal Regexp Match Indices was finalized recently, which means it will soon be part of the language. On…
-
5
votes1
answer35
viewsComparing captured keyboard strings to Rust
I’m trying to learn Rust and naturally I’m starting with "The Book". At the end of chapter 3 has 3 simple logic exercises, and one of them is the classic converter from Fahrenheit to Celcius. I…
-
4
votes3
answers273
viewsHow to implement Std::to_string for floating point?
This question may seem more like a request, but I’ve been researching it for 2 months and I don’t know how to solve it. I need to implement the std::to_string in C++ (headless) in a way that accepts…
-
4
votes3
answers29445
viewsHow to check if the String is null or blank in Java / Android
I went through this problem implementing a simple library of database queries sqlite in android and would like to share the solution with the community, I believe it will be useful since I have…
-
4
votes1
answer3396
viewsJava Regular Expression
I am programming in Java and need to filter a String from a regex using the method matches(). I can accept letters (a-z) or numbers (0-9), where that number can have 1 or n digits. I am using the…
-
4
votes4
answers313
viewsChanging a random string of characters using Stringbuilder
I have the following variables:: String mascara = "12****3*59**100*"; String numero = "12345768" There is a way to replace the asterisks of my variable mask by the values of my variable number?…
-
4
votes1
answer151
viewsQt String Encoding Problem
I’m having a problem encoding strings on Qt. By showing something in a QMessageBox or give a drawText in a paintEvent, my strings come out badly formatted, as if they were not in the correct…
-
4
votes2
answers801
viewsHow to change the value of a property given its name
In my program I have some classes where data is stored. For example Class1.alfa.dado = 66; Class1.beta.dado = 56; Class1.gama.dado = 37; The user will select in a Combobox one of the options you…
-
4
votes1
answer1498
viewsHow to replace characters from a String?
I have a small problem. My application receives a numeric string representing a value from the server. But the server sends, for example "100.00" and I need to put a comma in place of that point.…
-
4
votes2
answers5399
viewsMaximum number of characters in a String and Stringbuffer in Java
What is the maximum limit of characters that the types String and StringBuffer support in Java?
-
4
votes3
answers1232
viewsHow to extract a word from a PHP URL
In these examples below: +bbbbbbb2.virtua.com.br - take out the Virtua +000-74-4-000.paemt702.dsl.Brasiltelecom.net.br take out Brasiltelecom +111.222.22.222.dynamic. adsl.gvt. net.br - take the gvt…
-
4
votes1
answer487
viewsHow to use escape characters in a string in C#?
I am unable to scan a file that contains the EICAR (Standard Test File for Antivirus Scanning Methods) characters, as it contains escape characters such as " ", "()", "[]". I need a help to identify…
-
4
votes1
answer1801
viewsPicking specific amount of characters from a textbox
I am trying to get a specific amount of typed characters in a texbox, the current code is as follows: novaconfiguracao.CupomEstabelecimento = tb_NomeFantasia.Text.Substring(0,48).ToString(); In the…
-
4
votes3
answers3898
viewsHow to 'break' a text at each character range - Javascript
I would like to know how to 'break' (split function) a text every 8 characters in javascript for example: var teste = '1234567898' teste.split({a cada 8 caracteres}) //retorna ['12345678', '898'];…
-
4
votes4
answers453
viewsGet most used words from a string
I got a big string: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas porttitor non felis quis dignissim. Morbi varius arcu lorem, eget efficitur nibh interdum vitae. Aenean…
-
4
votes3
answers880
viewsInteger for String
In QT Creator 5, how do I convert Integer to string? In Visual Studio 2012 there was the command: std::to_string(10); But it doesn’t work on QT. I tried to: #include <QCoreApplication>…
-
4
votes2
answers1303
viewsPicking up content within a string
I’ll have a list of string in the following format: PERSON’S NAME( (LOGIN), an example would be this: ZACKSON MOREIRA MORGAN (zackson.morgan) Soon, I would need to get just what would be inside the…
-
4
votes2
answers2734
viewsRegular expression to retrieve strings starting with colons (:)
I need a regular expression to retrieve a list of strings starting with the two-point character (":") and ending with the space character or end of parentheses (")"). Example: String texto =…
-
4
votes1
answer243
viewsUse of bitmap font in Haxeflixel
I’m working on a game using the framework Haxeflixel 2D and I’m having some difficulties using bitmap fonts to render accented characters. But to make it easier I’m going to divide the question into…
-
4
votes2
answers755
viewsWhat does the dereferenced compilation error mean in Java?
In a test code (in Java), whose goal was to convert a string in one another string between upper and lower case letters, I received the following error at the time of compilation: error: char cannot…
-
4
votes2
answers2699
viewsRevert a string and add method to native objects in Python
In Python, we have the method reversewithin the List. It reverses the order of a list. Example: [1, 2, 3].reverse() // [3, 2, 1] However this method is not present in a string. example (Python):…
-
4
votes3
answers1952
viewsHow to get a text from a Qlineedit in Qt?
For example, I have a LineEdit, when I press a button I want to pick up what I wrote on this LineEdit and store a QString.
-
4
votes2
answers7228
viewsHow to remove spaces at the beginning and end of a string?
How to remove any number of spaces at the beginning or end of a C string#?
-
4
votes3
answers2212
viewsHow to use replace() for the last occurrence?
The method String#replaceFirst() is used to replace the first occurrence of a substring in a string, but how should I proceed if I want to do this with the last occurrence? The doubt is as follows…
-
4
votes2
answers1591
viewsWhat happens when I convert String to an array of bytes?
I have: String msg = "Texto a ser encriptado"; byte array[] = msg.getBytes(); What happens when I convert the string to an array of bytes? I’m concerned about an application I’m developing. I need…
-
4
votes1
answer3345
viewsHow to write the percentage symbol on a string in Java?
How to make the string accept the percentage symbol '%' ?
-
4
votes2
answers220
viewsAlternative to create a new method in a String object?
I have the following situation: I have a txt file of defined positions (type CSV, CNAB, etc) to process and extract values. For the purposes of understanding, follow the code I made and it’s working…
-
4
votes1
answer7264
viewsTake values separated by spaces in Java
Could someone explain to me how I can take values separated by spaces in Java? For example, the user informs all at once the following values: 1 2 3 and I have to put each value into a variable.…
-
4
votes3
answers476
viewsHow do I convert snake_case to camelCase (and vice versa) in Python?
How could I, in any way pythonic possible, convert a string snake_case for camelCase ? Example: snake1 = 'minha_string_snake_case' # minhaStringSnakeCase snake2 = '_teste_string' # _TestString…
-
4
votes2
answers682
viewsFilter String Array records by space-separated words in Java
How do I filter the records of a Array using the search terms separated by space ? Example: I have a Array String with the following records. bottle opener box with blue padlock Brass padlock 30mm…
-
4
votes2
answers348
viewsCreating string in PHP
It is possible to create a PHP variable of type string that contains so many bytes, that is, defined by the programmer? Example in C: char string[20]; In this case, string will always have 20 bytes,…
-
4
votes2
answers367
viewsRegex in dynamic string X characters, in dynamic content
Next, I have a page that generates a shuffled content with dynamic and non-dynamic strings, I need to take a dynamic value between separators |, it contains random data/strings around, which change…
-
4
votes1
answer957
viewsHow to save text in XML or txt or HTML file?
I am developing a program in C# and would like to know how to save the text of a RichTextBox format .xml or .html or .txt.
-
4
votes1
answer196
viewsProblem reading strings
I’m making an algorithm that gets the number of affairs, then a name with surname, one color and a size. He must make a comparison and print them ordered by color in ascending order, size in…
-
4
votes1
answer4227
viewsRemoving part of a string - C#
How can I remove my last characters from a string before reaching a certain character? For example: string url = "www.google.com/test"; I needed to remove the test word until I reached the "/"…
-
4
votes2
answers525
viewsRemoving strings from html files
In my project I need to read the contents of an HTML file as said in that question of mine. What happens is I can scan the file, but there’s a comment I wanted to take out. The peculiarity is that…
-
4
votes2
answers1229
viewsImprove code performance in C#
I’m doing some tests with some C# codes and during an analysis I realized that some high-peak problems happen when integer value conversions occur to string, in the vast majority the conversion…
-
4
votes1
answer1031
viewsHow to format a String with other elements using format()
I would like to know how to format a String 08041995 on 08/04/1995 using the Java format() method PrintStream ps = new PrintStream(arq); String valor = "250,35"; ps.format("R$ "+"%s", valor);…