Regex to match a listing

I’m trying to find a regex that will match a list pattern like:

A. banana
B. potato
C. apple

or

1. banana
2. potato
3. apple

even if the list doesn’t start with A or 1 like:

q. banana
r. potato
s. apple

can I get some help with this please?

EDIT: the regex should match only orders with alphanumeric characters, for example, this shouldn’t get matched:

$. banana
&. apple
//or
b. banana
a. apple


Source: stackoverflow-php

javascript regular expression to grab the state of 2 characters that is always following a city and a comma

Seems that google api for returns city and state from a zip code is just poorly made as they return a json object with address_components of which all have array list of elements with long_name and short_name

Now that would be fine , except that i cannot count on the state because in 3rd or the 4th array. :/

The ONE thing that i do see in common is a formatted_address of which example is

formatted_address: "Lake Villa, IL 60046, USA"

Since that is the case then seems that a regex is what i want

GOAL

var city = "Lake Villa"
var state = "IL" 

I don’t want to replace…. here is some regex i was trying to work with

 var formatted_address = "Lake Villa, IL 60046, USA";
 alert(formatted_address.replace(/(.+)-([A-Z]{2})$/, "$1, $2").replace("-", " "));


Source: stackoverflow-javascript

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