Regex to match words containing dots? -


(regex skill: 0)

let's want match urls might contain dot.

the parser i'm using has "url contains" feature, if type "you" it'll match "youtube.com/blahblah" , other url containing "you".

however, if use "youtube", it'll match "youtube.com" not "youtu.be".

so example, if wanted match apple, banana, app.le, banan.a, , ba.nana, not orange or ora.nge, have add (apple|banana) match words containing dots anywhere in them?

thanks!

you have match optional dots between every pair of letters:

(a\.?p\.?p\.?l\.?e|b\.?a\.?n\.?a\.?n\.?a) 

although allow number of dots. limit number of dots maximum 1, add negative ahead:

(?!.*?\..*?\.)(a\.?p\.?p\.?l\.?e|b\.?a\.?n\.?a\.?n\.?a) 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -