[regex-coach] regex not matching blank space after the beginning of the line?

Edi Weitz edi at agharta.de
Wed Dec 6 08:42:50 UTC 2006


On Tue, 5 Dec 2006 16:22:16 -0800 (PST), Dharma Wolford <dharmawolford at yahoo.com> wrote:

> In the following examples the double-quotes are only included for
> clarity, I'm not actually entering them into The Regex Coach.
>
> Here are two regexes I'm trying:
> #####################
> "\A*7[0-9][0-9]"
> "^*7[0-9][0-9]"
> #####################
>
> And these are lines of data I'm trying those against:
> ########################
> " 758"
> "  759"
> "  760"
> ########################
>
> Now what I'm expecting (and want) to happen is the leading blank
> space(s) on the left of the numbers, as well as the three digit
> numbers themselves, to be highlighted as a match.
>
> What DOES happen with both regexes is that the three digit numbers
> are highlighted, but not the leading blank spaces.

>From your description, I think what you actually want are regular
expressions like these:

  #####################
  "\A *7[0-9][0-9]"
  "^ *7[0-9][0-9]"
  #####################

The fact that your regexes match at all is counter-intuitive IMHO, but
it matches with what Perl does (which was one of the design goals of
CL-PPCRE): \A or ^ should only match the beginning of the string, but
the asterisk somehow "extends" this.

I agree that if there's a match, it should be highlighted completely,
so I will try to fix this in the next release, but I'm pretty busy
right now, and I don't consider this to be high priority (i.e. a
severe bug).

Thanks for the report,
Edi.



More information about the regex-coach mailing list