Used in a Sentence

substring

Definitions, parts of speech, synonyms, and sentence examples for substring.

Editorial note

If you're doing a substring match, then use a substring function.

Examples16
Definitions3
Parts of speech2

Quick take

(computing) A (possibly zero-length) string of characters that is contained in another string.

Meaning at a glance

The clearest senses and uses of substring gathered in one view.

noun

(computing) A (possibly zero-length) string of characters that is contained in another string.

verb

(computing, transitive) To extract a substring from.

verb

(computing, transitive) To take as a substring.

Definitions

Core meanings and parts of speech for substring.

noun

(computing) A (possibly zero-length) string of characters that is contained in another string.

verb

(computing, transitive) To extract a substring from.

verb

(computing, transitive) To take as a substring.

Example sentences

1

If you're doing a substring match, then use a substring function.

2

How about substring searching: Boyer- Moore searches backwards, Rabin Karp computes hashes while others simulate automata.

3

In Bioinformatics, this is known as the Smith-Waterman algorithm [2] and the result would satisfy the requirements of fuzzy substring matching.

4

Read in mb of data in a String, substring a couple kb out, and tada!

5

From the start, you're taught that Strings are immutable objects, so you probably understand that `.substring()` produces a new instance object.

6

This had some harmful effects for those expecting substring() would always share the underlying char[].

7

Is it really more common that people do substring and expect the rest to be thrown away than the other way around?

8

Here is an explanation of the change to `substring()`[0] and why it was done.

9

Without prior knowledge of the implementation, why would you expect a reference to a substring to hold the entire original string in memory?

10

You can't just deprecate substring() which is a function that is used in what 90% of the millions of Java applications around the world.

11

I'd hate to be writing a grammar every time I want to do a substring match.

12

I definitely think it is more common for a programmer to expect that if they make a substring, and never reference the original string again, only the substring would remain in memory after GC.

Quote examples

1

The description in the Java 7 API for substring is "Returns a new string that is a substring of this string." That does not suggest any sharing with the parent string; it says "new string".

2

This is why the article's code example yields such a huge difference in memory usage in Java 6 vs Java 7; it is effectively a sort of "anti-pattern" when used against the new `substring()` method.

3

In this respect, the Java/Oracle folks likely decided that optimizing for the "parsing/tokenization" use case (where you make lots of substrings from a large original string and thus it makes sense to use the same underlying character array) was more novel and less frequent than the use case of "just pulling a small substring from a much larger one and then discarding the large one."

Proper noun examples

1

Substring optimization for small but not larger strings.

Frequently asked questions

Short answers drawn from the clearest meanings and examples for this word.

How do you use substring in a sentence?

If you're doing a substring match, then use a substring function.

What does substring mean?

(computing) A (possibly zero-length) string of characters that is contained in another string.

What part of speech is substring?

substring is commonly used as noun, verb.