Example of search of at least 3 bars:
var expr = /\/(.*\/){2,}/;
alert(expr.test('http://exemplo.com')); // exibe false
alert(expr.test('http://exemplo.com/ola/')); // exibe true
This expression looks for a text with 3 bars with any number of characters between them (including none).
Editing: The above expression searches for the longest possible text, starting with a bar, ending with a bar and having at least 3 bars. Following the philosophy in @mgibsonbr’s commentary of better efficiency, which I agree, a more restrictive expression with less processing, finds only the first three bars with the fewest possible number of characters between them would be:
var expr = /\/.*?\/.*?\//;
Since the author of the question only wants to verify, with regular expression, whether the condition is true, this last expression is more appropriate.
Good answer. I would put the repeat operator no- Greedy efficiency (eg.:
.*?
), but it works one way or another.– mgibsonbr