Regex with input

It is necessary to make that in input it was possible to drive and with a format “AB 12” (the letter a letter a space number number). If the input does not match the format – just to replace the void.


Source: stackoverflow-javascript

Validade if string contains a regex string

I have the following string below which was extracted by DOM Document:

$scripts = $doc->getElementsByTagName('script');
$script = $scripts->item($i); 
$string = $script->getAttribute('src');// Save the string 'jquery-3.2.0.min.js'

I have 3 ways to check if this string is a jquery:

  • “jquery(?:-|.)([d.]d)[^/].js;version:”
  • “/([d.]+)/jquery(?:.min)?.js;version:”
  • “jquery.*.js”

In that case how can I validate the above string using one of these 3 commands?


Source: stackoverflow-php

Rewrite URL to hide id

I have the following url on my website:
www.example.com/video?id=468/video-title

I want to rewrite it in htaccess so that it appears as:
www.example.com/video/video-title

What regex do i need to use in this scenario for the proper rewrite?


Source: stackoverflow-php

Regex find a string with hypones in it

I’m trying to find email within text that is being followed by a key word ‘domain’
preg_match_all("/domain.+b([a-z0-9-]+@[a-z]{2,3})/im", $input_lines, $output_array);

my input data is

here is some text
capture this domain hi-there-welcome.co
and this domain should be captured yes90well.com
but not this link nolink.com
but not this line of no domain on it

I should be able to capture hi-there-welcome.com and yes90well.com


Source: stackoverflow-php