preg-match

Get error in using skyscanner Api of flight pricing in php

心不动则不痛 提交于 2019-12-24 07:29:14
问题 i am following link for accessing flight live prices Skyscanner API for all airport locations and Travel API using CURL i have replace api key with my apikey. PHP Code: <?php $varApiKey = '?apiKey=API KEY'; $country_code = 'IR'; $originplace = '51.845159,-8.492835-latlong'; $curency = 'EUR'; $destination = 'DUB-iata'; $start_date = date('Y-m-d'); $dateOneMonth = strtotime($start_date); //$end_date = date("Y-m-d", strtotime("+1 month", $dateOneMonth)); $end_date = ''; $audult = '1';

How can I check a form POST only contains letters on multiple fields using preg_match?

爷,独闯天下 提交于 2019-12-24 07:00:25
问题 I have this current code that allows me to check the users first name from a registration form to ensure it only contains letters, spaces and dashes. However how can I enable checking multiple fields (e.g. last name too). /* Checks if the first name only includes letters, dashes or spaces */ if(preg_match("/^[a-zA-Z -]+$/", $_POST['firstname']) == 0) $errors .="Your name must only include letters, dashes, or spaces."; I've tried the following but it seems to only check one or the other, not

How to validate a url with lots of querystrings

不问归期 提交于 2019-12-24 04:43:10
问题 I have an auto site and I am having a feature called SAVE SEARCH, which saves the search a user has made on the site for future use. What I am doing is that I am saving entire url in the database. But I need to validate it as a valid url. It looks like this. http://www.anywebsite.com/cars.php?postcode=CV2+5AS&distance=&make=&min_price=&max_price=&category_type=&body_type=&fuel=&colour=&transmission=&year_of_registration=&mileage=&engine=&doors=&seller=&keywords=&sort=PRICE_LOWEST&referer_url

Seprate movie name and year from moviefile name

假如想象 提交于 2019-12-24 03:48:11
问题 I have a file name like this Birdman.2014.DVDSCR.X264-PLAYNOW.mkv Divergent (2014) 720p Blu-Ray x2649 [Dual-Audio][English DD 5.1 + Hindi DD 5.1] - Mafiaking - TeamTNT ExClusive.mkv Cradle 2 The Grave 2003 HDTVRip 720p Dual-Audio[Eng+Hindi] ~ BRAR I have to seperated movie name and year For getting year in use perg_match like $s="Divergent (2014) 720p Blu-Ray x2649 [Dual-Audio][English DD 5.1 + Hindi DD 5.1] - Mafiaking - TeamTNT ExClusive.mkv"; if (preg_match('/\b\d{4}\b/', $s, $matches)) {

check directory path for symbols range and “..” up directory sign

旧时模样 提交于 2019-12-24 03:18:47
问题 I try to build RegExp to validate(preg_match) some path string for two following rules: path must consists only symbols from given range [a-zA-z0-9-_\///\.] path will not consist an up directory sequence ".." this is a correct path example: /user/temp and the bad one: /../user UPD: /user/temp.../foo will also be correct (thanks to Laurence Gonsalves ) 回答1: Consider this: $right_path = '/user/temp'; $wrong_path = '/../user'; $almost_wrong_path = 'foo/abc../bar'; $almost_right_path = 'foo/..

how to check valid decimal point number with Regex?

橙三吉。 提交于 2019-12-24 00:53:27
问题 how can i check number is valid with below string. last 2 digit may content decimal value or may not. below are the code which i have already tried with preg_match but couldn't get any success $newPrice = "2,264.00"; or // $newPrice = "264.00"; if (!preg_match('/^[+-][0-9]+(\,[0-9]+)?%?$/', $newPrice)) { echo "not valid"; }else{ echo "valid"; } exit(); above both price is correct as per allowed format. 回答1: The regex has 3 parts; [0-9]{1,3} 1-3 digits (,[0-9]{3})* An optional repeated part of

PHP preg_match to find relevant word

笑着哭i 提交于 2019-12-24 00:03:32
问题 I have a variable with value like this : $sentence = "When it comes time to renew your auto insurance policy, be aware of how your carrier handles renewals"; And I have array variables with value below : $searches = array('aware', 'aware of', 'be aware', 'be aware of'); $replaces = array('conscious', 'conscious of', 'remember', 'concentrate on'); I would like to find just 'be aware of' and then replace with 'concentrate on'. Output like below : When it comes time to renew your auto insurance

Regex is not working for some cases - PHP

为君一笑 提交于 2019-12-23 21:54:34
问题 I have a number of string patterns from which I filter out my data and insert it into a database. Now, I have to handle strings that my old regex is not able to match correctly. This is my regex: $re = "/(?:Expiration Fee: )?(\d+)\s+((?:[a-zA-Z0-9\/]+\s+)*)(?:\(([a-zA-Z]+)\)\s+)?(?:>([0-9.]+)\s+)?(?:(\d+-\d+)\s+)?(?:\((\d{1,2}(?::\d{2})?[AP]M)\)\s+)?(?:@\s+([\d.]+))/"; My complete code: $re = "/(?:Expiration Fee: )?(\d+)\s+((?:[a-zA-Z0-9\/]+\s+)*)(?:\(([a-zA-Z]+)\)\s+)?(?:>([0-9.]+)\s+)?(?:(

PHP: using REGEX to get the tablename from a mysql query

牧云@^-^@ 提交于 2019-12-23 19:02:56
问题 Consider these three mysql statements: select * from Users; select id, title, value from Blogs; select id, feelURL, feelTitle from Feeds where id = 1; Now im not very good at REGEX, but i want to get the table name from the mysql query. Could someone possibly create one for me with a little explanation. Thanks, 回答1: Try: preg_match('/\bfrom\b\s*(\w+)/i',$query,$matches) This will not work if the query has more than 1 table. Basically the regex searchs for the complete word FROM in the query

preg_replace() not finding ending delimiter?

别来无恙 提交于 2019-12-23 15:29:34
问题 I use preg_replace() alot but I'm not a genius at it. If I start up a function and deliberately key in all the smilies that I want to use e.g. <?php function parse_emotes($body){ $body = preg_replace("#\:p#i", "<img src='images/emotes/tongue.png' alt=':p' title=':p' />", $body); //they continue like i said return $body; } ?> but today I tried to change it up and use mysql to let me just insert and delete them as I please without playing in my code, but when I tried it, it only throws Warning: