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:

I want to rewrite it in htaccess so that it appears as:

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
and this domain should be captured
but not this link
but not this line of no domain on it

I should be able to capture and

Source: stackoverflow-php