Questions tagged as 'string'


How to abbreviate words in PHP?

I have common information such as people's names and addresses, and I need them to contain a maximum of 30 characters without cutting words. Example: 'Avenida Natalino João Brescansin' => 'Av. Natalino J. Brescansin' 'Joaquim Rossafa Nas...
asked by 09.05.2016 / 15:43

Get index backwards

Imagine I have the following string: string texto = "Stackoverflow em Português"; If I want to know the index of the first space, just: int index = texto.IndexOf(" "); But in this case I have two spaces, and I would like to get the ind...
asked by 18.11.2015 / 11:30

Function that lists letters of the alphabet

How to convert the letters of the alphabet into an array of numbers according to its sequence? The array should start from # 1, not zero. So the letter A would be 1 , B would be 2 , C would be 3 , an...
asked by 15.03.2015 / 17:01

str_split does not work well in UTF-8 containing string?

I want to iterate a string with foreach . For this, I learned that I should use the str_split function, which separates each character from the string into a array . But this operation does not work as expected when using str...
asked by 01.02.2016 / 19:50

Detect Line Break

I have the following function: if (str.match(/\d\d\d\d\d\.\d\d\d\d\d/)) { var codigo_velho = str.match(/\d\d\d\d\d\.\d\d\d\d\d\/); result = "1"; } How do I change this function so that it detects line break in match ? For ex...
asked by 26.05.2014 / 04:34

How does the function int deal with the character \ n?

I've created a list: usuarios = ['123\n','123\n4'] I tried to convert index 0 to integer using int() int(usuarios[0]) Result: 123 But when I tried to do the same with index 1: int(usuarios[1]) result:    ValueError:...
asked by 02.12.2018 / 20:43

How to convert an html string into a jQuery object?

How to convert an HTML to a jQuery object? var objeto = '<div id="minhaDiv"><span id="meuSpan">Span</span></div>';     
asked by 18.09.2015 / 19:09

What is the difference between "String (1)" and "new String (1)" in Javascript?

Why in Javascript is it possible to call String as a function and also instantiating? See the example: var str1 = new String(1) var str2 = String(1) console.log("Valor é %s e o tipo é %s", str1, typeof(str1)); console.log("V...
asked by 28.11.2016 / 14:29

How to give split in a String that contains blanks in the beginning?

For the problem in question, I need to remove all special characters and spaces and count the possible new outputs. My intention is to separate the String with the split() method. For this, based on another expression I saw, I created thi...
asked by 20.08.2018 / 22:18

How do I delete a character within a string?

In this code I read two strings and remove all first letters in common with the second string . But how do you put a null character in place of this letter in common in the two strings ? My code looks like this: char str1[15], str2[15];...
asked by 12.09.2014 / 20:34