Simple PHP Regex question
Posted
by Dave Kiss
on Stack Overflow
See other posts from Stack Overflow
or by Dave Kiss
Published on 2010-04-18T14:13:01Z
Indexed on
2010/04/18
14:33 UTC
Read the original article
Hit count: 396
Hi all,
I'd like to validate a field in a form to make sure it contains the proper formatting for a URL linking to a Vimeo video. Below is what I have in Javascript, but I need to convert this over to PHP (not my forte)
Basically, I need to check the field and if it is incorrectly formatted, I need to store an error message as a variable.. if it is correct, i store the variable empty.
// Parse the URL
var PreviewID = jQuery("#customfields-tf-1-tf").val().match(/http:\/\/(www.vimeo|vimeo)\.com(\/|\/clip:)(\d+)(.*?)/);
if ( !PreviewID ) {
jQuery("#cleaner").html('<div id="vvqvideopreview"><?php echo $this->js_escape( __("Unable to parse preview URL. Please make sure it's the <strong>full</strong> URL and a valid one at that.", 'vipers-video-quicktags') ); ?></div>');
return;
}
The traditional vimeo url looks like this: http://www.vimeo.com/10793773
Thanks!
© Stack Overflow or respective owner