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
-
4
votes5
answers5371
viewsSplit a string with empty spaces
I’m trying to divide an entrance of the following kind: 1444771699,Andre Alves,SAQUE,-500.00,,200 I’m trying to use the strtok, but it ignores the empty space. Any idea of how to split the string…
-
4
votes1
answer199
viewsConvert string to specific format in date
I have a string "sex, nov 6" and need to convert to DateTime. I’m doing it this way: DateTime datetime = DateTime.Parse(gridT.Columns[e.ColumnIndex].HeaderText.ToString()); But it’s not working. How…
-
4
votes4
answers872
viewsI need different ways to rearrange characters within a string, how do I do that?
I would like answers in C, C#, or just an algorithm, but preferably an implementation already in the C# language because that’s what I’m using. For example, suppose I have to find out if a number is…
-
4
votes4
answers5878
viewsConvert String to Decimal
And I’m having trouble properly converting this string in decimal. decimal.Parse(txtValor.Text)=meuVen.Valor; When I put the conversion in front, it shows error after the =. I don’t know how to…
-
4
votes2
answers1261
viewsCompare value at each String position in Java?
I’m having trouble comparing a value in each position of a String, follows the example below: parametro = "30,60,90"; private int countVirgulas(String parametro) { int count = 0; for (int i = 0; i…
-
4
votes3
answers655
viewsHow to use a dictionary value to call a specific Python function?
I’m trying to use a dictionary to identify each function to a value, and call them over the program. My code is below (example): #!/usr/bin/env python menuOpt = { 1 : "valor", } #Main if __name__ ==…
-
4
votes3
answers210
viewsFunction contrary to TRIM
How to insert characters in a field varchar in Mysql? For example, in the update with Trim vc you can remove certain characters from a field varchar... but and add ? Example: update tabela set campo…
-
4
votes1
answer933
viewsConvert $Scope to string in ng-model by Angularjs
I am in doubt, according to the tutorial of Angular the ng-model only accepts one $scope if he goes string, giving: Error: [ngModel:numfmt] expected `1234` to be a number Possible then convert to…
-
4
votes1
answer103
viewsHow to delimit the number of characters written per line in a "txt" output in R?
I’m writing a filelog and I want to print it on an A4 sheet. One of the parts of this filelog has a variable, with the following structure:…
-
4
votes1
answer442
viewsCopying string stored in pointer
What is wrong? #include <stdio.h> #include <string.h> int main(void) { char *str= " teste"; int j = 0; while(str[j] == ' ') j++; memcpy(str, &str[j], strlen(&str[j])+1);…
-
4
votes2
answers161
viewsProtecting data in memory
I read several articles on cryptography etc... The cryptography reported by posts was a success in my program, however some data remains in memory being vulnerable to Assembly readers in real time.…
-
4
votes3
answers6684
viewsHow to create a dynamic variable
I have a field(input text), and would like to get the value, and pass as variable. In other words, pass the value of this text field into the: var valor do campo aqui ; See the example I leave:…
-
4
votes4
answers715
viewsWhat’s wrong with the c-code?
The task: Pedrinho and Zezinho need to study solving mathematical expressions for a test they will do. For this, they want to solve many exercises before the test. As they know how to program, so…
-
4
votes1
answer979
viewsFunction that converts hexadecimal to binary
Is there any function equivalent to bin2hex() from PHP to C#? I need to convert a hexadecimal to binary. I tried to use the TryParse but it hasn’t worked out.
-
4
votes3
answers4243
viewsHow to check if return from Ajax is JSON or String?
My code is like this: sendAjax(new FormData(this), function(retorno) { if(retorno.isArray) { $(".erro-login strong").text("ID: " + retorno.id + " usuário: " + retorno.usuario);…
-
4
votes1
answer157
viewsLibrary equal to C# 6.0 runtime Interpolation string
Does anyone know of a library that interpolates at runtime on strings? I know it could be done using Replace(), but I don’t want to pass the list with all the variables. For example: Programa de…
-
4
votes2
answers503
viewsHow to hide a string in C, so that it is not readable in compiled code?
I have a string Hello World, but I don’t want to keep it as Hello World in C, I would like to keep it as some value in Base64, aes or binary, or similar, so that it is not readable in the code. How…
-
4
votes1
answer1072
viewsChar comparison, ignoring the case sensitive
The proposal is to create a program that compares n first positions of the two vectors and returns saying whether or not they are equal. So far so good, but I do not know how to ignore the case…
-
4
votes1
answer256
viewsWhat is the difference between "Exception.Message" and "Exception.Tostring()"?
I’ve read some answers regarding try-catch and on the Exceptionbut I still have doubt about the difference in Exception.Message and Exception.ToString(): What’s the difference between one and the…
-
4
votes1
answer79
viewsIs using "Touint64()" to format string correct?
Looking for a practical way to format string I came across the following: Convert.ToUInt64(string).ToString(@"00000\-000"). It is a good pathic to use this method to format strings? There is a…
-
4
votes1
answer117
viewsCan I declare a library within a class in C++?
I need to use type variables string, the problem is that I cannot include libraries within my classes in Code::Blocks, there is some way to include the library string/string.h in my class in C++?…
-
4
votes2
answers842
viewsUsing Array.Foreach to modify the collection
I want to remove spaces from the beginning and end of the string (Trim) in all positions of array, but none of the ways below worked. What am I doing wrong? var optionArray = new string[] { "in the…
-
4
votes3
answers197
viewsAccount with PHP in the order it is in the string
I need an order of reckoning to be in string be done in the order it is in. For example: $string = '(10*10)+(30-5)/2'; I need PHP to interpret this not as a string, but rather as a calculation and…
-
4
votes3
answers163
views"Carry" variables between functions, appears strange character in place?
In function main when I print a char, it appears a strange code like a hexa: But when I print the same char in another function it appears normal. char tempA[100] = "1111"; int main () {…
-
4
votes2
answers480
viewsSingle vs. Double Quotes in PHP Regex
whereas I own a path which I wish to verify with preg_match if it is the desired path, what is the difference between the two operations to follow? // Single quoted string…
-
4
votes1
answer2052
viewsConvert Roman number to decimal
I’m doing an exercise where I need to convert a typed Roman number, and the program returns a decimal number. My algorithm: import java.util.Scanner; public class NumerosRomanos { public static void…
-
4
votes4
answers1757
viewsEmpty input cannot receive zero
I have a form with more or less 5 inputs, at any given time inputs will be worthless, and I want to find out what the lowest value between them, but whenever there is one or more inputs voids it…
-
4
votes2
answers855
viewsMake comparison using String.Contains() disregarding Casing
I need to check if a given term exists within a string (in SQL is something like like '%termo%'). The point is, I need this done without considering Casing of the two strings. How can I do that?…
c# string comparison case-insensitive cash-sensitivityasked 7 years, 10 months ago Jéf Bueno 67,331 -
4
votes1
answer1323
viewsMake comparison using String.Contains() disregarding accents and case
I need to check how to make a comparison between strings, in C#, using the method Contains() that so disregards the sensitivity of accents and marry of a string. Example: var mainStr = "Acentuação";…
-
4
votes3
answers129
viewsSplit a string that contains scores
I’m trying to split the following string Eu irei amanhã à casa. E tu vens? To get the following result inside a php array array( [0] => eu [1] => irei [2] => amanhã [3] => à [4] =>…
-
4
votes5
answers590
viewsRemove chunk from a string
have a string, example: 32137hyb8bhbhu837218nhbuhuh&3298j19j2n39 I want to remove (clear) from the string everything that comes after the &. Please, how to do this?…
-
4
votes2
answers396
viewsConvert string value to hexadecimal without changing format
I am using the following code in a Class. public Int16 Endereco = 0x7302; byte[] Data = BitConverter.GetBytes(Endereco); Array.Reverse(Data); [...] I would like to receive the value for the variable…
-
4
votes2
answers220
viewsHow to map and obtain only one property or field of a query?
I’m using the Dapper that has the purpose of map properties of objects. See a practical example: var servico = conexao.Query<Servico>(statement.ToSql(), new { IdServico = id }).First(); That…
-
4
votes1
answer488
viewsUsing Concat to concatenate array of strings
I was seeing about strings and that they are immutable and cannot be added to them in quantity otherwise they will be very slow. The recommendation is to use the StringBuilder. But I also saw that…
-
4
votes1
answer777
viewsHow to transform a string into HTML C#
I am using a component and need to load it with HTML snippet that comes in a variable. For this I created this Jquery: $(document).ready(function(){…
-
4
votes1
answer660
viewsCheck if all items in a string are different?
How can I check if all the items in a string are different ? For example: x:"abcdefga" = False y:"abcdefg" = True Since x[0] == x[7], soon would be False. But in case I would use that condition on a…
-
4
votes5
answers1088
viewsDigits in a java string
How do I find out how many digits a java string has ? For example, user entered with "exemplo123", the string has 3 digits. I’m using this function but it’s not working: private static int…
-
4
votes1
answer341
viewsCheck if String has '+' character
I need to search in a string if it has the + character, like this: teste = teste.replaceAll("+", "e"); but I return this error: java.util.regex.Patternssyntaxexception: Dangling meta Character '+'…
-
4
votes2
answers4812
viewsHow do I check if there is a special character or number in a string in C?
I am confused in logic to check if it has other characters than alphabetic ones. I thought of the following logic, but I think it is wrong: char nome[30]; scanf("%s", nome); int especial = 0;…
-
4
votes4
answers7713
viewsHow to detect if a variable is null?
I’m trying to validate a simple form in Python 3 and I want to make sure it doesn’t record the information if the field nome is empty, but when I make a if to check whether the variable name is…
-
4
votes1
answer359
viewsWhat is the main difference between the Knuth-Morris-Pratt and Boyer-Moore algorithms
I know that the KMP(Knuth-Morris-Pratt) is used to find a Y text in X, tries to define a pattern in Y, and then saves this pattern in an array. And I also know that the BM(Boyer-Moore) works best…
-
4
votes1
answer1398
viewsWhen to use String and Stringbuilder
There is another question about What is the most appropriate way to concatenate strings?. It explains the possible types of concatenations in C#. But when should we use System.String and when we…
-
4
votes4
answers806
viewsAssignment of Java Arrays
I have two String Arrays and I have to compare them. After the comparison I must assign the repeated values in another Array. My problem is that I wish to assign only the Strings repeated without…
-
4
votes2
answers75
viewsReturn a case sensitive record
I own a constraint in the bank that is all with your name capitalized. As I do a count to find the same one using the UPPER? 'Cause I want to pass the where a tiny name to return. This one of mine…
-
4
votes1
answer41
viewsHow to search a character in a set of javascript strings
I have a set with certain strings, it is a vector, need to be done searches for characters in this set. Case: Be it V my set of strings contemplated by: ["ana", "paula", "cris", "voa",…
-
4
votes3
answers1011
viewsHow to compare strings differentiating case from case?
I have following code: Usuarios user = DataModel.Usuarios.Where(x => x.Login.Equals(login,StringComparison.OrdinalIgnoreCase) &&…
-
4
votes2
answers1903
viewsHow to convert Lowercase String to UPPERCASE?
My question is in switch (opcao). To perform one of the cases it is necessary to enter with capital letters. Is there any string or Java character conversion function from lowercase to uppercase…
-
4
votes1
answer95
viewsString Contains Empty returns true
Why when using the Contains("") in a string not empty returns true? Example if ("MinhaString".Contains("")) { Console.WriteLine("String contém vazio"); }…
-
4
votes2
answers280
viewsWhat’s the difference between creating a string with quotes and square brackets?
I’ve always created the strings with the quotation marks, like this: local minhaString = "Eu sou uma string" I downloaded a source to give a study in the language and I came across the following way…
-
4
votes1
answer671
viewsI want to check if the string contains only letters?
#include<stdio.h> #include<stdlib.h> #include<ctype.h> #include<string.h> #define tam 50 main(){ struct cadastro{ char nome[tam]; }; struct cadastro dados; printf("Nome:");…