markwk
markwk

Reputation: 135

Regex Extract but exclude random number bit

Regex parsing problem, I am putting together an embed video provider module for Drupal.

For basic video pages the url is like this: http://v.ku6.com/show/EJEiKXHN1avFezNi.html so this regex works fine to parse the video code:
'@v.ku6.com/show/([^"\&/]+).html@i',

But many pages use this pattern http://v.ku6.com/special/show_4086312/ZP0DCEnRVpK4BiEU.html so I need to extract "ZP0DCEnRVpK4BiEU" but exclude the random 4086312 numbers there.

here's the regex stuff I have so far: '@v.ku6.com/special/show_[what goes here?]/([^"\&/]+).html@i',

Upvotes: 0

Views: 160

Answers (2)

stema
stema

Reputation: 92976

Try this:

@v.ku6.com/special/show(?:_\d+)?/([^"\&/]+).html@i

the (?:) is a non capturing group, the ? afterwards says it can be there or not and the \d+ is at least one number

Upvotes: 1

Arc
Arc

Reputation: 11286

what goes here?: \d+ (digits)

Upvotes: 2

Related Questions