[plt-dev] Regexp matching at string edges

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Oct 25 12:49:18 EDT 2009

On Oct 25, Dave Gurnell wrote:
> Point of note - string-titlecase does both the upping and the downing  
> of case, which may be a good or a bad thing depending on what you're  
> trying to achieve:
>      (string-titlecase  "Welcome to PLT!") ; => "Welcome To Plt!"

I was about to suggest this:

  (regexp-replace* #px"\\b\\w" "welcome to PLT!" string-upcase)

but it doesn't work because "\\b" matches everywhere the search

`regexp-split' and the related functions do some regexp tweaking to
make this work as expected:

  (regexp-split #px"\\b" "foo bar")

The tweaking turns the regexp into one that cannot match an empty
string at the edge of the (sub) string.  It works nicely in that last
case, but now I see that this rule still doesn't work for the above

  (regexp-split #px"\\b\\w" "foo bar")

Perhaps the regexp tweaking thing is not enough then...

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the dev mailing list.