On 2/27/02 5:47 PM, "Kevin Ballard" <kevin at sb dot org> wrote:
> On 2/27/02 8:38 PM, "Jerry Hamlet" <jerry at hamletzone dot com> wrote:
>
>> What's the special notation "" about? I'm not familiar with that.
>
> Seeing as the RegEx searchpattern is a string, it has to be enclosed in
> quotes ("). This means if you want the quote character in your string, you
> can't simply type a quote ("). REALbasic solved the problem of how to type a
> quote in a string by making it so if you have two quotes ("") in a string,
> it turns into one quote and is part of the string. So two quotes ("") is
> identical to \x20 in the RegEx, but is slightly easier to read.
Ahhh- It's an RB thing. Good to know.
>
> Oh, and I know [^>]* is greedy. But the greediness makes it go faster, no?
> It just grabs all characters up until the first >. That doesn't seem like it
> would take too long to do. But for the link itself, I decided not to stop at
> the first ">" because of reasons previously stated (but only when the link
> is enclosed in quotes).
When you have a greedy pattern before what you want to match is that the
RegEx has to backtrack from the point that it finds the ">" character to
fulfill the rest of the pattern. This happens all the way back to the
opening "<" where it eventually decides that it can't fulfill the pattern.
It helps sometimes to translate your regex patterns into plain english. I.e,
for your example it would go something like this: "Find a left-angle bracket
character. Then grab all characters that are not a right-angle bracket. Ok,
now back up till you find either 'src', 'href' or 'background'..." at this
point what the RegEx is doing is stepping back a character at a time trying
to fulfill that request, and it will try every character up to the opening
angle bracket.
Jeff Friedl explains it a lot better than I.
-jerry
+---------------------------+
| Jerry Hamlet |
| Web Designer/Programmer |
| www.hamletzone.com |
| jerry at hamletzone dot com |
+---------------------------+
|