Hi Greg,
Could it be that there is some space or invisible character before the
question mark in your pattern ?
*<a href="/posts/.+□?/index\.html">*
If it is the case that explains the greedyness.
You can check the characters in your pattern with menu: Window > Palettes >
Character Inspector.
HTH,
Jean Jourdain
On Thursday, December 19, 2024 at 12:13:38 AM UTC+1 GP wrote:
> Hmm... I don't know what's going wrong with your usage of either grep (<a
> href="/posts/.+?/index\.html"> or <a
> href="/posts/[a-z].+?[a-z]/index\.html">). Either one just matches only the
> <a href="/posts/post-name/index.html"> parts of text strings including
> strings also containing <a href="/search/index.html">Search here.</a> in
> them.
>
> The <a href="/posts/[a-z].+?[a-z]/index\.html"> will restrict finding
> those stings with only lower case letters in the first and last characters
> of post-name but that isn't something you're having a problem with.
>
> Could you post a short example containing a <a href post and <a href
> search string where your grep is glumping the two links together?
>
> On Wednesday, December 18, 2024 at 9:03:23 AM UTC-8 Greg Raven wrote:
>
>> I use Grep in BBEdit a lot for cleaning up websites, but now there's a
>> situation where I'm missing something.
>>
>> I'm redoing a site from WordPress to static, so there are a bunch of
>> links that look like:
>>
>> <a href="/posts/post-name/index.html">Post name</a>
>>
>> I need to change these so the link looks like:
>>
>> <a href="/posts/post-name.html">Post name</a>
>>
>> This seems as though it should be simple to find these instances with:
>>
>> <a href="/posts/.+?/index\.html">
>>
>> But if a paragraph contains:
>>
>> <a href="/posts/post-name/index.html">Post name</a>. <a
>> href="/search/index.html">Search here.</a>
>>
>> It glumps both links (and anything / everything in between) into one
>> found result.
>>
>> I sorta got it to work with this:
>>
>> <a href="/posts/[a-z].+?[a-z]/index\.html">
>>
>> But there has to be a more straightforward way. What am I missing?
>>
>
--
This is the BBEdit Talk public discussion group. If you have a feature request
or believe that the application isn't working correctly, please email
"[email protected]" rather than posting here. Follow @bbedit on Mastodon:
<https://mastodon.social/@bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/bbedit/13007ff9-5374-4b32-a33a-b3af40ceda31n%40googlegroups.com.