grep for searching

36 views
Skip to first unread message

ejonesss

unread,
Feb 5, 2022, 6:09:04 PM2/5/22
to BBEdit Talk
i was wondering what is the grep i would need to find all occurrences of a word that begins with

ftp://ftp.scene.org/pub/demos/artists/0xf/drunkchessboard.zip


for example i want to find all lines who has file of “.zip" and begins with “d"

drunkchessboard.zip

i got the finding .zip part ok that is how i extracted all the zips from a massive 600000 line list

now the tricky part is detecting the “/d” part



Chris

unread,
Feb 5, 2022, 6:38:12 PM2/5/22
to bbe...@googlegroups.com
I’m on my phone so I can’t test it but:
d\w+\.zip

--Chris(topher)?

On Feb 5, 2022, at 3:09 PM, ejonesss <ejones...@gmail.com> wrote:

i was wondering what is the grep i would need to find all occurrences of a word that begins with
--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/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 bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/9029aa96-cd05-4724-8126-4ea34ef23e99n%40googlegroups.com.

Kaveh

unread,
Feb 6, 2022, 4:39:09 AM2/6/22
to bbe...@googlegroups.com
not clear for me what you want to do. can you put a sample of input lines and output needed?

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/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 bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/9029aa96-cd05-4724-8126-4ea34ef23e99n%40googlegroups.com.


--
Kaveh Bazargan PhD
Director
Accelerating the Communication of Research

jj

unread,
Feb 6, 2022, 6:02:19 AM2/6/22
to BBEdit Talk
Find:

(?<=/)(?:d([^\s/]|\\\x20)*?\.zip)\b

Or commented:

(?x)                (?# Use multi-line and comments)
(?<=/)              (?# Look behind a slash not including it in the match)
(                   (?# Start of capture \1)
    d               (?# Literal 'd')
    (?:             (?# Start non capturing parentheses)
        [^\s/]      (?# NOT [whitespace or slash] character)
    |               (?# or)
        \\\x20      (?# Backslash escaped space)
    )               (?# End non capturing parentheses)
    *?              (?# Match 0 or more greedily)
    \.              (?# Literal '.')
    zip             (?# Literal 'zip')
)                   (?# End of capture \1)
\b                  (?# Word boundary)

Should match:
ftp://ftp.scene.org/pub/demos/artists/0xf/drunkchessboard.zip
ftp://ftp.scene.org/pub/demos/artists/0xf/d.zip
"ftp://ftp.scene.org/pub/demos/artists/0xf/d0xf+==&amp;.zip"
/path/to/unicode/files/d你好.zip
/path/to/document\ with_escaped_space.zip

Should NOT match:
ftp://ftp.scene.org/pub/demos/artists/0xf/d.zipped      -- Wrong extension.
/path/to/document with_unescaped_space.zip              -- Has unescaped space.
document.zip                                            -- Missing /.

HTH

Jean Jourdain

ejonesss

unread,
Feb 6, 2022, 12:58:08 PM2/6/22
to BBEdit Talk
jj that seems to work to work to process lines containing so i can break down file of 200000 ftp links to each letter for easier downloading

thanks
Reply all
Reply to author
Forward
0 new messages