Strings Solution - D Programming Language

Menu

- Learn
- Documentation
  - Language Reference
  - Library Reference
  - Command-line Reference
  - Feature Overview
  - Articles
- Downloads
- Packages
- Community
  - Blog
  - Orgs using D
  - Twitter
  - Calendar
  - Discord (community-run)
  - Forums
  - IRC
  - Wiki
  - Issues
  - Contributing
  - Contributors
  - Foundation
  - Security Team
  - Donate
  - Sponsors
- Resources
  - Tour
  - Books
  - Tutorials
  - Tools
  - Editors
  - IDEs
  - run.dlang.io
  - Visual D
  - Acknowledgments
  - D Style
  - Glossary
  - Sitemap

Search
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

# Strings Solution

#### Strings Dersi Problem Çözümleri

1. Although some of the functions in Phobos modules will be easy to use with strings, library documentations are usually terse compared to tutorials. You may find especially the Phobos ranges confusing at this point. We will see Phobos ranges in a later chapter.
2. Many other functions may be chained as well:

       import std.stdio;
       import std.string;

       void main() {
           write("First name: ");
           string first = capitalize(strip(readln()));

           write("Last name: ");
           string last = capitalize(strip(readln()));

           string fullName = first ~ " " ~ last;
           writeln(fullName);
       }

3. This program uses two indexes to make a slice:

       import std.stdio;
       import std.string;

       void main() {
           write("Please enter a line: ");
           string line = strip(readln());

           ptrdiff_t first_e = indexOf(line, 'e');

           if (first_e == -1) {
               writeln("There is no letter e in this line.");

           } else {
               ptrdiff_t last_e = lastIndexOf(line, 'e');
               writeln(line[first_e .. last_e + 1]);
           }
       }

Copyright © 1999-2026 by the D Language Foundation | Page generated by Ddoc on Wed Aug 5 15:38:51 2026