[draft] New std.regex walkthrough

Dmitry Olshansky dmitry.olsh at gmail.com
Wed Mar 14 03:14:02 PDT 2012


On 14.03.2012 0:54, H. S. Teoh wrote:
> On Tue, Mar 13, 2012 at 11:27:57PM +0400, Dmitry Olshansky wrote:
>> For a couple of releases we have a new revamped std.regex, that as
>> far as I'm concerned works nicely, thanks to my GSOC commitment last
>> summer. Yet there was certain dark trend around std.regex/std.regexp
>> as both had severe bugs, missing documentation and what not, enough
>> to consider them unusable or dismiss prematurely.
>>
>> It's about time to break this gloomy aura, and show that std.regex
>> is actually easy to use, that it does the thing and has some nice
>> extras.
>>
>> Link: http://blackwhale.github.com/regular-expression.html
>>
>> Comments are welcome from experts and newbies alike, in fact it
>> should encourage people to try out a few tricks ;)
> [...]
>
> Yay! Updated docs is always a good thing. I'd like to do some
> copy-editing to make it nicer to read. (Hope you don't mind my extensive
> revisions, I'm trying to make the docs as professional as possible.)
> My revisions are in straight text under the quoted sections, and inline
> comments are enclosed in [].
>
>
>> Introduction
>>
>> String processing is a kind of daily routine that most applications do
>> in a one way or another.  It should come as no wonder that many
>> programming languages have standard libraries stoked with specialized
>> functions for common needs.
>
> String processing is a common task performed by many applications. Many
> programming languages come with standard libraries that are equipped
> with a variety of functions for common string processing needs.
>
I like equipped ;)

>
>> The D programming language standard library among others offers a nice
>> assortment in std.string and generic ones from std.algorithm.
>
> The D programming language standard library also offers a nice
> assortment of such functions in std.string, as well as generic functions
> in std.algorithm that can also work with strings.
>
>
>> Still no amount of fixed functionality could cover all needs, as
>> naturally flexible text data needs flexible solutions.
>
> Still no amount of predefined string functions could cover all needs.
> Text data is very flexible by nature, and so needs flexible solutions.
>
>
>> Here is where regular expressions come in handy, often succinctly
>> called as regexes.
>
> This is where regular expressions, or regexes for short, come in.
>
>
>> Simple yet powerful language for defining patterns of strings, put
>> together with a substitution mechanism, forms a Swiss Army knife of
>> text processing.
>
> Regexes are a simple yet powerful language for defining patterns of
> strings, and when integrated with a substitution mechanism, forms a
> Swiss Army knife of text processing.
>
>
>> It's considered so useful that a number of languages provides built-in
>> support for regular expressions, though one though one should not jump
>> to conclusion that built-in implies faster processing or more
>> features. It's all about getting more convenient and friendly syntax
>> for typical operations and usage patterns.
>
> It's considered so useful that a number of languages provides built-in
> support for regular expressions. (This doesn't necessarily mean,
> however, that built-in implies faster processing or more features.  It's
> more a matter of providing a more convenient and friendly syntax for
> typical operations and usage patterns.)
>
> [I think it's better to put the second part in parentheses, since it's
> not really the main point of this doc.]

I think putting that much in parens is a bad idea, but your wording is 
clearly superior.

>
>
>> The D programming language provides a standard library module
>> std.regex.
>
> [OK]
>
>
>> Being a highly expressive systems language, it opens a possibility to
>> get a good look and feel via core features, while keeping it's
>> implementation within the language.
>
> Being a highly expressive systems language, D allows regexes to be
> implemented within the language itself, yet still have the same level of
> readability and usability that a built-in implementation would provide.
>

Nice!

>
>> We'll see how close to built-ins one can get this way.
>
> We will see below how close to built-in regexes we can achieve.
>
>
>> By the end of article you'd have a good understanding of regular
>> expression capabilities in this library, and how to utilize it's API
>> in a most straightforward way.
>
> By the end of this article, you will have a good understanding of the
> regular expression capabilities offered by this library, and how to
> utilize its API in the most straightforward way.
>
>
>
>> Examples in this article assume the reader has fairly good
>> understanding of regex elements, yet it's not required to get an
>> understanding of the API.
>
> Examples in this article assume that the reader has fairly good
> understanding of regex elements, but this is not required to get an
> understanding of the API.
>
> [I'll do this much for now. More to come later.]
>
>

Thanks.

-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list