Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 69099

A string is a sequence of characters. It is commonly used to represent text or a sequence of bytes. Use this tag along with the appropriate programming language being used.

7 votes
4 answers
20k views

Summing digits of an alphanumeric string

I am going through the Java CodingBat exercises. Here is the one I have just completed: Given a string, return the sum of the digits 0-9 that appear in the string, ignoring all other characters. R …
alanbuchanan's user avatar
  • 1,302
7 votes
3 answers
11k views

Removing Asterisks and neighbors from a string

I am going through the CodingBat exercises for Java. I got to this problem: Return a version of the given string, where for every star (*) in the string the star and the chars immediately to its l …
alanbuchanan's user avatar
  • 1,302
5 votes
1 answer
2k views

Finding common elements, ignoring duplicates, in two given string arrays

Here is the one I have just completed: Start with two arrays of strings, a and b, each in alphabetical order, possibly with duplicates. … Return the count of the number of strings which appear in both arrays. …
alanbuchanan's user avatar
  • 1,302
5 votes
1 answer
115 views

Generating a topographic string

I am working my way through some exercises, using Java, to learn about programming. I have just finished the following Code Golf challenge: Here is some example input, so I can explain what the pr …
alanbuchanan's user avatar
  • 1,302
5 votes
2 answers
3k views

Counting length-2 substrings that are common to two strings at the same offset

I just completed this one, an exercise that requests the comparison of substrings of two strings: Given 2 strings, a and b, return the number of the positions where they contain the same length 2 substring … So "xxcaazz" and "xxbaaz" yields 3, since the "xx", "aa", and "az" substrings appear in the same place in both strings. …
alanbuchanan's user avatar
  • 1,302
5 votes
3 answers
5k views

Using recursion to count substrings (with exceptions to the rule) in Java

I am going through the CodingBat exercises for Java. Here is the one I have just finished: Given a string, compute recursively the number of times lowercase hi appears in the string, however do no …
alanbuchanan's user avatar
  • 1,302
5 votes
3 answers
1k views

Case insensitively removing a substring, efficiently

I have just completed this one: Given two strings, base and remove, return a version of the base string where all instances of the remove string have been removed (not case sensitive). … The test strings involve digits. Is it problematic to be 'converting' these to lower and/or upper cases? Should I deal with those before testing the alphabetic strings? …
alanbuchanan's user avatar
  • 1,302
2 votes
3 answers
1k views

Returning matching substrings, of n length, at the beginning and end of a string

I am going through the Java CodingBat exercises. Here is the one I have just completed: Given a string, return the longest substring that appears at both the beginning and end of the string withou …
alanbuchanan's user avatar
  • 1,302
1 vote
4 answers
5k views

Redacting everything in a string except a particular word

I am working through the Coding Bat exercises for Java. Here is one I have just completed: Given a string and a non-empty word string, return a version of the original String where all chars have …
alanbuchanan's user avatar
  • 1,302