Questions tagged as 'string'

2
answers

How can I check if a string contains another in Javascript?

I would like to check if a string contains another, as if it were a String.contains() method but apparently there is no method that does this. Does anyone know of a similar method that does the same thing?     
asked by 30.01.2014 / 11:35
2
answers

How to create regexReplace for a delimiter?

I have the following content: 123|321|1234\|56\|teste\||123 I would like to make a regex replace that would replace all | with line break and ignore | escaped with \ , so I would like to get the following return:...
asked by 21.01.2014 / 12:08
2
answers

How can I turn line breaks into br / in JavaScript?

In PHP, we can convert a line break to a <br/> through the function nl2br . What about JavaScript? How can I do this in a secure way? I decided to ask the question because I do not know if a simple replace("\n") f...
asked by 13.10.2015 / 15:36
1
answer

How to set TitleCase using regex in Javascript?

I have this function: var titleCase = function(s) { return s.replace(/(\w)(\w*)/g, function(g0, g1, g2) { return g1.toUpperCase() + g2.toLowerCase(); }); } If I call her by passing something she works ri...
asked by 28.04.2014 / 19:45
2
answers

Comparison of search algorithms within text strings

I'm trying to implement the following algorithms for searching expressions within Java text strings: Knuth-Morris-Pratt (KMP), Brute Force, Boyer-Moore, and Levenshtein How could you show the similarity obtained to perform a comparison betwee...
asked by 07.08.2015 / 04:49
2
answers

Differences and use of Strings vs. CharSequence

Many methods in Java expect parameters CharSequence , but the code runs normally when I pass String without conversion, for example: String mensagem = intent.getStringExtra(MainActivity.MENSAGEM); TextView t = (TextView)findViewB...
asked by 17.01.2014 / 12:43
2
answers

Divide a String dynamically based on screen size

I'm working on an android app and at some point I get a String from a web-service that is pretty big, and the client wants that String (which will be shown in an EditText ) is divided into multiple parts, forming a pagination type (I thought...
asked by 18.05.2015 / 20:43
4
answers

How to extract digits from a string in Python and add them together?

I need to decompose a string into Python, separating letter and numbers, and perform the sum of these numbers. For example: string ="96h11k" From this string I need to extract the numbers 9, 6, 1, 1 and add them: 9 + 6 + 1 + 1 = 17. Act...
asked by 28.11.2014 / 18:19
3
answers

What is the difference between using single quotes and double quotation marks in C #?

In PHP, when we use single quotes or double quotation marks, both forms have the function of declaring a string . There is only one small difference. I'm now starting a C # study. When I tried to declare a string with single quotation mark...
asked by 28.05.2016 / 21:33
2
answers

How to count the amount of occurrence of a substring within a string?

I have the following return:    EXCEPTION, ClassException, EXCEPTION, Exception Message I'd like to get the number of times the String EXCEPTION appears using Regex . I used the following code: Pattern.compile("(EXCEPTION)",Pa...
asked by 16.01.2014 / 13:47