So I have this input pattern in HTML: <input name=”firstnamereg” type=”text” pattern=”[/p{L}+/u ]+”> But When I use the preg_match it does not work: $regexFirstANDLastname = “/[/p{L}+/u ]+/”; preg_match($regexFirstANDLastname, $_POST[“firstnamereg…
Tag: preg-match
How can I convert from a{a{} b{}} to a[a[],b[]] using php preg_match?
How can I convert the above structure to the following result. I tried many patterns, but failed. I tried with regex pattern and explode function. I Failed in Recursive function. I want to get the output as array or json. How can i do it.Thanks…. Answer An approach in two steps: the first checks the who…
PHP Preg_match for authorized characters
i’m a noob in regular expressions. Il would like to prevent a form for special characters. The characters auhorized are : I made a preg_match rule that makes problems I know that i should encapsulate special chars but i didn’t know to achieve this. Can you help me please ? Thanks in advance. Answe…
preg_match string from meta name
I want to preg_match number “20,956” from $url1 and number “2,894,865” from $url2 $url1: $url2: Tried this to work for both of urls, it works for only $url1 but not in $url2 Any Idea to make it work for both $url1&2? Answer You can use See the regex demo. Details: d – a digit…
How to use preg_match to extract a version number and date from a string?
I have this string: I am looking to use preg_match to extract the version number and the date from it and put it into an array, I have the following code but I’m definitely doing something wrong here: I’m unsure how to deal with the = in the string and the hyphen in the middle or even if the above
Weird PHP Regex Preg_Match Bug?
My PHP version is PHP 7.2.24-0ubuntu0.18.04.7 (cli). However it looks like this problem occurs with all versions I’ve tested. I’ve encountered a very weird bug when using preg_match. Anyone know a fix? The first section of code here works, the second one doesn’t. But the regex itself is vali…
php – word between space and tab (or: sort attendance report alphabetically)
I am trying to extract the last name of a attendance report for sorting it alphabetically by last name. The attendance report (should be an .cvs) looks like this: (Tab was extracted for the post, so here: I open it via fgetcsv and find the word between space and a tab: Output looks like this: Testme Left I do…
PHP Regex Match Specific Pattern between Quotes
I have strings with the following pattern: adfadfadfadfadfadfafdadfa”externalId”:”UCEjBDKfrqQI4TgzT9YLNT8g”afadfadfafadfdaffzfzfzxf Basically, I need to find “externalId” and extract it’s value in between the quotes that follow. The length of the value can change so i…
PHP using preg_match to match items in array with values that can or not contain accent characters
The preg_match must match any of the words in the $string variable (as long as they are at least 3 chars long) with any of words in the $forbidden array, but here’s the issue: If the $string contains …
How can i display my preg_match results in various divs so they can have multiple results under the correct heading?
Forgive me if this is simple but I have a for each loop that searches JSON data for results from a search. I then have some preg_match statements that will look at some of the tags within the JSON and if their is a match display the thumbnail in a div. and currently this all works. But it currently displays