diabolickman Posted May 16, 2012 at 09:09 AM Report #455979 Posted May 16, 2012 at 09:09 AM Olá! Estou a tentar fazer uma expressão regular para o youtube, mas isto está complicado. Estive a fazer uma breve pesquisa e encontrei a seguinte: http://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)(\w*)(&(amp;)?[\w\?=]*)? mas ao implementa-la não funciona, talvez por azelhice e tar algo mal feito: function checkLink($field){ $teste = '/^(http://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)(\w*)(&(amp;)?[\w\?=]*)?)+{8,70}$/'; return( preg_match($teste, $field) ); } Alguém tem alguma sugestão? Obrigado 🙂
brunoais Posted May 16, 2012 at 09:11 AM Report #455980 Posted May 16, 2012 at 09:11 AM (edited) function checkLink($field){ $teste = '/^(http://(?:www\.)?youtu(?:be\.com/watch\?v=|\.be/)(\w*)(&(amp;)?[\w\?=]*)?)+{8,70}$/'; return( preg_match($teste, $field) ); } Alguém tem alguma sugestão? Obrigado 🙂 Dica: Repara nos delimiters que usas. Edited May 16, 2012 at 09:12 AM by brunoais (não é preciso tanto quote) "[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31 Life is a genetically transmitted disease, induced by sex, with death rate of 100%.
diabolickman Posted May 16, 2012 at 09:45 AM Author Report #455984 Posted May 16, 2012 at 09:45 AM Dá para dares uma ajudinha, por favor?🙂 Expressões regulares não sou grande coisa :/
brunoais Posted May 16, 2012 at 11:39 AM Report #456027 Posted May 16, 2012 at 11:39 AM Quando usas um certo carater como delimitador ele não pode aparecer no resto do regex sem ser "escapado" (escaped). Um regex: "$gdfsas/dhgb=hfu$" é equivalente a: "/gdfsas\/dhgb=hfu/" que é equivalente a: "=gdfsas/dhgb\=hfu=" "[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31 Life is a genetically transmitted disease, induced by sex, with death rate of 100%.
diabolickman Posted May 16, 2012 at 02:10 PM Author Report #456066 Posted May 16, 2012 at 02:10 PM Posso dizer que não percebi?:s
brunoais Posted May 17, 2012 at 09:41 AM Report #456325 Posted May 17, 2012 at 09:41 AM Posso dizer que não percebi?:s Há vontade, sim. (vou assumir que não percebeste). tenta ver isto: http://php.net/manual/en/regexp.reference.delimiters.php e depois vê aqui: http://php.net/manual/en/function.preg-match.php Se ainda n perceberes pede outra vez. Aqui o pessoal está para ajudar. "[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31 Life is a genetically transmitted disease, induced by sex, with death rate of 100%.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now