Questions tagged as 'string'

5
answers

Test for string padding

When I read a post about good programming practices, more related to validating string fills, I came across the following: Check too slow: string ret = String.Empty; if (string.IsNullOrEmpty(ret)) Slow check: string ret = String.Empt...
asked by 29.08.2018 / 14:03
4
answers

How to find hashtags in a string and store them in an array?

I have a system for posting content on a certain social network of our company. When the user enters text with hashtags , I need to detect all of them and store them in an array. Example:    Hello, I'm posting this # question to #...
asked by 19.10.2015 / 17:47
3
answers

How can I replace a part of a string by itself plus the character "~"?

How can I replace a part of a string with itself plus the "~" character? I am doing this as follows: only when the string has two equal numbers like the 51 that comes shortly after AP and the contained in 17 51 3322 Replace does...
asked by 15.06.2016 / 20:49
3
answers

Fill string with leading zeros

I'm doing an OS work and need to turn decimal numbers into binaries. So that's fine, because the method below takes an integer and converts to binary. My problem is this: When I put it, for example (integer 1), it returns me correctly 1. But...
asked by 30.10.2014 / 11:34
4
answers

Identify if all characters are equal [duplicate]

I have the following code that works perfectly. In it I have a string and check if all the characters are equal or not: var numbers = '1111121111', firstNumber = numbers.substr(0,1), numbersEquals = true; for(let i = 1; i <...
asked by 19.12.2016 / 19:56
1
answer

Why is it better to use char [] than String for passwords?

Using Swing, the getPassword() method of JPasswordField returns an array of char[] characters instead of returning String as getText() (which by the way is deprecated). Should I not use String to stor...
asked by 04.09.2017 / 19:26
1
answer

Extensive number for number

I would like to convert an extended number to normal int; example: FunçãoParaConverter("trinta e dois") // retorna 32 FunçãoParaConverter("mil vinte e quatro") // retorna 1024 FunçãoParaConverter("mil t...
asked by 15.12.2017 / 20:16
6
answers

How do I transform an array that is in a string to array in javascript?

I have a string representing an array as follows: var = "['aaaaa', 'bbbbb', 'ccccc', 'ddddd']"; I want to be able to transform this array that is in the string into an Array to perform manipulations. var = ['aaaaa', 'bbbbb', 'ccccc', 'ddd...
asked by 31.03.2017 / 16:27
2
answers

Receive variable value without passing parameter

I have the following method: private string toCamelCase(string text) { text = string.Format("{0}{1}",text.Substring(0, 1).ToLower(),text.Substring(1)); return text; } To use it I need to call it like this: toCamelCase("OlaMundo");...
asked by 26.11.2014 / 15:20
1
answer

What is the difference between String name="test" and String s4 = new String ("Peter");

What's different about assigning a value to the variable by creating an object and assigning unboxing to a direct value? String s4 = new String("nome"); String nome = "nome"; System.out.println("nome == s4 " + (nome == s4)); //retorna fals...
asked by 05.09.2017 / 04:07