Claude: Death by Regex
Yesterday I used Claude for Chrome to help me storyboard a video for American Style. I gave him explicit instructions to browse the web for images and videos of 9/11 and the war in Afghanistan, preferring widescreen, high-resolution photos and videos. I added the requirement that they must all be open-source. I then provided the lyrics to the song we are storyboarding and asked him to create an index of the media related to the lyrics.
The song is 6 minutes long. I asked for 200 media items.
Claude proceeded to browse the web for over an hour, unattended, and identified 800 initial media items that matched the subject matter, from which it selected 200 based on my constraints. It created an index file which grouped into 10 sections according to the lyrics. which it cited inline.
That was impressive, but I needed to download all the media. So I asked Claude to crawl the list and download each piece of media, creating a new index file with local filenames. He started to doing the task, but after a few minutes stopped and prompted me with a question.
The web navigation was slow and prone to errors. He was having trouble downloading too many links and stopped. He said it was going to take 3-4 hours or more and was likely to fail to acquire all the media. Claude then proposed we create a Python script instead that would read the index file and download all the links. That sounded reasonable, so we proceeded to do that. Claude created the script and I ran it.
Pretty academic. The file was already in markdown language and easy to parse. Or so I thought.
The script failed immediately, zero downloads. What followed was an aggravating round of at least 15 revisions to that script as I copied non-trivial Python code and error messages back and forth with Claude, pointing out where it was incorrect and trying to get regular expression matches to work with spaces, underscores, slashes and invisible embedded characters from the file that he created.
That’s right, Claude got stuck on regex. Seriously stuck. All programmers should hate regex because they’re so damn complicated. They’re powerful, like a loaded gun. Claude kept telling me, “this is the final version” and “this will run correctly”. Fail. He finally said “we are going in circles” and he was right. I finally realized I was running against the Sonnet model, trying to conserve tokens since it was such an academic task. So I switched models to the latest Opus and in just a few revisions the script started working.
Mostly. It still failed to download after 10 files or so, blocked by the web server for being a greedy client. So I had to tune it to wait up to a minute between requests. I just started it, and it’s running as I write this. Estimated time to completion is 3-4 hours. I ran out of tokens for my session so the last round of debugging was on my own.
I found all of that astonishing given the great success I’ve had with Claude Code building the Interactive Circle of Fifths, and my latest full-stack application, Correlation Studio. Amazing, mind-blowing results and surreal conversations. Months worth.
But there he was, dead on the hill of regex. “We keep going in circles”. Famous last words.
American Style – Audio and Lyrics
The song in development is American Style. Featuring vocalist John Serrano and drummer Bill Ray, this track is a musical exploration of the psyche of American warfare post 9/11. It’s a hard rock / progressive metal track full of dramatic intensity and explosive power, drawing out the story of a sniper who goes to Afghanistan to avenge his countrymen. The collaboration was one for the books.
American Style on Spotify • American Style on Soundcloud • American Style on Bandcamp
I’m going to Afghanistan
That’s where I’ll make my final stand
Like Johnny Spann and everyone
Who loved him
I know you may not understand
I find myself the kind of man
To cross the line in the sand
For something
This is war, American style
Nightmares come of age
Deliver me from rage
This is war
The target looks like every man
I see him in the market stand
I could take him now
If I’m not wrong
Before he gets to Pakistan
I’ll track him through the mountains and
He’ll give me one reason
To be strong
This is war, American style
Nightmares come of age
Deliver me from rage
This is war
Winter’s come, it bites my hands
Like every day I’ve walked these lands
I’ve found another reason
For a man’s revenge
With every shot I’ve made my stand
So many men so much demand
I’ll never leave, I’ve joined the band
Until the very end
This is war, American style
Nightmares come of age
Deliver me from rage
This is war
Face to face, hand to hand
Fighting for the promised land
Every target, every man
Squeeze and go
I look at him and his demands
I know he’ll never understand
I’ve always had the upper hand
He will not know
This is war, American style
Nightmares come of age
Deliver me from rage
This is war