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
-
8
votes1
answer577
viewsHow to count touches (letters, spaces and symbols) in PHP?
I made a program that extracts my annotations from my code and creates a file txt to be a little manual. I made a format to make it cooler: +-----------+ | | | ESPECIAIS | | | +-----------+ It takes…
-
8
votes3
answers4527
viewsRemove currency formatting and take only the PHP number
i write in the database the values of the products in this way: For example: R$ 5.000,00 How do I do in PHP to make this number stay 5000? That is to say "shape"? Do you have a function that fits…
-
8
votes1
answer7864
viewsFunction to generate random alphanumeric characters
I need a C# function that manages a String of random alphabetic and numerical characters of size N.
-
8
votes2
answers1853
viewsHow to convert an html string to jQuery object?
How to convert a string HTML in a jQuery object? var objeto = '<div id="minhaDiv"><span id="meuSpan">Span</span></div>';
-
8
votes2
answers1714
viewsInvoking an object’s method - reflect
It is possible to invoke a method from the contents of a variable of type String? for (Object vlr : dados) { String metodo = "getCodigo()"; contato.setAttribute("codigo", vlr.metodo); }…
-
8
votes1
answer11054
viewsStreamwriter Special Characters with Encoding.ASCII C#
I am writing in a file via Streamwriter using the encoding Encoding.ASCII. A situation has appeared where I need to write the letter "Ç". Only if I try to do that, the file leaves the character "?".…
-
8
votes5
answers631
viewsstr_split does not work well in string containing UTF-8?
I want to iterate a string with foreach. For this, I learned that I must use the function str_split, that separates each character from the string to a array. However, this operation does not work…
-
8
votes1
answer1772
views -
8
votes1
answer583
viewsUse "Fieldbyname" or the associated variable?
When I have a ClientDataset, one MemoryTable or a Query, what’s the difference if I take the value of a field using FieldByName() or the variable associated with the field? In the example below, I…
-
8
votes5
answers1240
viewsHow to split a string into specific Javascript sizes?
I need to share a string in specific Javascript size. I know it’s possible to use the Join to transform a string in a array letter: 'hello'.split('') However, I need a way where I can determine the…
-
8
votes3
answers3514
viewsHow to store any string in C?
How do I store a string (input) without knowing the size of this string, for example: #include<stdio.h> int main (){ char nome[]; /* a array não tem tamanho determinado porque o input ainda…
-
8
votes2
answers123
viewsFind words between characters { }, and remove text in PHP?
$comoesta = "{A,O} {portador,portadora} é o mais {especializada,especializado} para o serviço ."; If it’s male: $comodeveficar = "O portador é o mais especializado para o serviço "; If it’s female:…
-
8
votes4
answers220
viewsHow many Strings are created in the codes below?
How many Strings the JVM actually creates during the execution time of the code snippets below? 1: String s1 = "s1"; 2: String s2 = new String("s2"); 3: String s3 = "s3"; String s4 = s3 + "s4"; 4:…
-
8
votes2
answers107
viewsWhy are some string methods static?
I am learning C# after already working with other languages, I noticed that some methods need to be called by the class string.Concat("123","456") I usually use in other languages this way…
-
8
votes1
answer2048
viewsWhat is the difference between replace() and replaceAll()?
I was reading the documentation to properly develop a mask and save without it. However I came across this doubt of methods replace and replaceAll for my string. What is the difference between the…
-
8
votes3
answers184
viewsSearch in String
I have a String of dynamic size and I need to search for the "#" cross to the next blank. I tried to use split, but without success. String texto = "oi tudo bem como vai #01?"; String[] t ; t =…
-
8
votes3
answers605
viewsHow to give a Regex before a string? And select?
What I need to do is this: let’s assume that the string is -> :. However I want to select "only" the string before the : using the Regex. To make it clearer: "select that word: another word here"…
-
8
votes1
answer141
viewsWhat are the differences between "String" and "str" in Rust?
I know there are (apparently) two main types of string in Rust: str, which, as far as I can tell, is a primitive type; String, which, as far as I know, is part of the standard library std of…
-
8
votes1
answer147
viewsHow to use a predefined interpolation in Javascript
I was reading in ES6 documentation about interpolation (or Template strings) and saw that I can create "escaped templates", as in the example below: class InvalidParamError extends Error { static…
-
7
votes4
answers1385
viewsHow to replace {vars} in a string?
I have a string string str = "Bem vindo {Usuario}. Agora são: {Horas}"; I want to replace {Usuario} by a name and {Horas} by the current time, how can I do this?…
-
7
votes4
answers4319
viewsString concatenation in SQL
I perform a query in a table in my Mysql database that returns the following fields to me: usuarioId nome sobrenome idade sexo escolaridade modeloNome hora Follow the sql below: SELECT…
-
7
votes1
answer360
viewsProblem with types in function parameter
When executing the following code: function foo(string $text) { echo $text; } foo('bar'); I get the following error: PHP Catchable fatal error: Argument 1 passed to foo() must be an instance of…
-
7
votes1
answer146
viewsIs there a specific type for passwords other than String in . Net?
I see very commonly the use of strings to store passwords in the program memory, not only on . Net, but in all the programming languages I’ve used. At first, I don’t see a problem in it. But as I…
-
7
votes4
answers1804
viewsShould I check dates with Datetime or regex?
I have seen two different ways to check whether a date is valid. In a "modern" way, with DateTime: $date="2014-02-04"; $dt = DateTime::createFromFormat("Y-m-d", $date); return $dt !== false…
-
7
votes2
answers402
views"Variable system" with regular expressions
I have a file like this: %usuario: 'Anônimo' Olá <b>%{usuario}</b> (This is just an example and this is not the real case), but I believe that if I were to explain the real problem it…
-
7
votes1
answer41918
viewsTraverse string and replace a specific PHP character
I wanted to replace, in a string, all character occurrences & by a e (or remove it). The character may be in the middle of a word or appear several times in the same string. Example: Original…
-
7
votes2
answers483
viewsLike taking multiple groups in a Regex?
public string site = "http://www.tibia.com/community/?subtopic=worlds&world=Aurera"; private Regex nomedochar = new Regex("subtopic=characters&name=(?<player>.*?)\" >"); public…
-
7
votes4
answers20874
viewsHow to extract only numbers from a string?
I want to extract only the numbers of a CPF that is in a string in this format; 111.222.333-44 You have to return only: 11122233344…
-
7
votes2
answers4442
viewsHow to delete a specific Listview item?
I would like to ask a question: I have one ListView, in which his Adapter is clarified in the same Activity and the content of Adapter (as strings) are in another class, in another package. How do I…
-
7
votes3
answers392
viewsString contains a certain word
I’d like to check if a string contains a certain word. String = "oi\ntchau\nhi\nbye" To string is divided by \n (jumps line), I would like to check between each line, if it contains the whole word,…
-
7
votes2
answers2337
viewsHow to make "Replace" replace all occurrences of a word without taking uppercase or lowercase?
The function Replace supersedes all occurrences of a word or expression, but taking into account uppercase and lowercase: string str = "Hello WorLLd";//Substitui só os 'l' e não o 'L' str =…
-
7
votes1
answer898
viewsWhat is the difference between puts() and fputs()?
I know both functions are for display strings on screen. But what’s the difference between them? Which one is better to use?
-
7
votes4
answers2028
viewsIdentifying common snippets in two PHP strings
I need to compare non-standard strings in PHP. I have 2 strings as below: $primeira = 'asdasdasdTESTEasdasdasdasd'; $segunda = 'lkijlikjTESTEilkjik'; How do I dynamically know if the first and…
-
7
votes4
answers9003
viewsInvert a 3-digit number in C
I need to make a program that the user type a three digit number and the program reverses that number for example 123 -> 321, I’d like to know the logic to do that, because I can’t think of…
-
7
votes1
answer125
viewsLoop with array + string
I’m trying to do something like: a = {move1="oi", move2="oi2"} for x=1, #a do print(a.move..x) end I can’t explain it very well, but what I’m trying to do is this: print(a.move..x) getting…
-
7
votes4
answers4670
viewsSelect string at random
I need a way to randomly create a string between some options. Let’s say I have the strings "A" "B" and "C", it would be possible for Java to choose randomly?
-
7
votes1
answer767
viewsChange of char variable content
I’m having trouble working with files and handling char. CODE char *fileTipoDespesaDefault; char *fileTipoPagamentoDefault; FILE *fileTipoDespesa; FILE *fileTipoPagamento; /** * tipos : 1 =>…
-
7
votes2
answers718
viewsHow do I add two strings in C#?
I have a method that will take two strings and return the sum of them in string format. I use string because there will be +-30 digit numbers. I’m having trouble converting to add. :/
-
7
votes2
answers160
viewsPrevent Insertion of Zalgo Text in Inputs
I have a Aplicação Web that has user registration, I would like to know how to prevent the user send as name, email (registration data) a Zalgo Text. Example of Zalgo Text: T̃͟͏̧̟͓̯̘͓͙͔o̤̫͋ͯͫ̂…
-
7
votes2
answers5604
viewsHow do I repeat a string in Python?
The question is simple: How do I repeat a string in Python? I’m used to PHP. When I want to repeat a string in PHP, I do so: var $str = 'StackOverflow'; str_repeat($str, 5); // Imprime:…
-
7
votes6
answers14101
viewsString Format with Javascript
Aiming at the String.Format from C#, which is very easy to use, I searched for something similar to be used in my Javascript codes. I found some rather problematic implementations, aiming at this, I…
-
7
votes3
answers119
viewsHow to remove a link from a string in Javascript?
How can I remove the link from a Javascript string? str = "hey olha isso http://google.com, legal né?" var test = str.description.replace(/.*?:///g, ""); Expected result: hey look at that, cool…
-
7
votes3
answers27933
viewsPython str.replace() doubt
I have the following text:: 'box 1 is blue, box 10 is green, box 100 is empty' I want to replace 'box 1' with 'package 2', so I do: >>> texto = 'caixa 1 é azul, caixa 10 está verde, caixa…
-
7
votes1
answer182
viewsIs it possible to use MD6 in C#?
Speaking of hash, it is possible to use MD6 in C#? Someone would have an example of the use in a simple string? In my research I found nothing very objective.
-
7
votes4
answers658
viewsHow to test the condition on a vector?
I have to make a program that reads a text, where each first letter of each word in the text is replaced by a character (*). I cannot compile correctly, I believe the problem is in my condition…
-
7
votes3
answers49921
viewsConvert string number to PHP integer
I’m converting a string to an integer in PHP, but at the return of settype($variavel, "integer"), or (int)$variavel bring me a null value or equal to 1. Have another way to try the conversion? The…
-
7
votes2
answers1833
viewsError: Object of type 'float' has on Len
I was thrashing simple operations on the Python interpreter, and the following command made me curious: >>> b = 3.12; len(b) With the following error: Traceback (Most recent call last):…
-
7
votes2
answers1242
viewsHow to multiply an "X" character as many times as you want?
Is there a method that multiplies an "X" character as many times as I want? example: I have the character "P" P x 5 = "PPPPP" Is there any ready method in . Net?…
-
7
votes2
answers1283
viewsHow to convert ASCII to binary?
I’m trying to implement the conversion of a text to binary, I found one on the internet: static string ASCII_binary(string texto) { string converted = string.Empty; byte[] byteArray =…
-
7
votes3
answers23806
viewsSize of a String
A char in the C language occupies 1 byte in memory. Ex: char ch;//a variável ch esta ocupando 1 byte na memória And a vector of char best known for string, its size in bytes will be counted…