Pattern for a regular expression

Hi.

I would like some help with a pattern for a regular expression.   The string that I need to find will always have 3 or more "/" characters in the string surrounded by alphanumeric characters.   By that rule, the first or last character cannot be "/".

Between each "/" character, there would be a number of alphanumeric characters but the number of characters and their composition of those characters does vary.

There are no spaces in the string. All the characters are numbers or letters.  By example the string being sought might look like the following.

204A/abcd23/1124343/abc53/213c

 Thank you for your help.
peispudAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Russ SuterConnect With a Mentor Commented:
(?:\w+[/]{1}){3,}\w+

Open in new window

translates as
match the following expression but don't capture it
(
Alphanumeric, one or more repetitions
A / character, exactly once
)
the above group at least 3 times followed by
Alphanumeric, one or more repetitions

Or...
^((?:\w+[/]{1}){3,}\w+)(?![/])$

Open in new window

This is a full string match and will only produce a match if the above conditions are met AND
 - the entire string matches
 - the last character in the string is not a / character
0
 
peispudAuthor Commented:
Perfect!   You gave me two great answers with explanation.  

Thank you!
0
All Courses

From novice to tech pro — start learning today.