Topics Tagged with preg_match

Hello everyone i have a pattern that checks the given url is correct or not and this is working perfectly fine, but when i give arabic chrarcters in pattern it return false because of invalid URL. I want english and arabic chracter to check in URL. where i can do change or what i can add in this pattern so this pattern can also validate arabic character with english // check if URL is valid format $pattern = '/^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w]([-\d\w]{0,253}[\d\w])?\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.,\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.,\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.,\/\d\w]|%[a-fA-f\d]{2,2})*)?$/'; $isLink = preg_match($pattern, $url); // Returns true if a link

Hello Everyone, As the title implies I need help extracting a name out of a string, my knolwedge of regular expressions is pretty limited. The strings I will be working with will look like this: 12345 Aragon Denvil L. 123-1234 A123456 AragonD AragonAD@fake.mail.us 1000001234 ABC-ABC 123ABCD123 ABCD 1234 A1234 ABC12345A1 AB123AB 17-Feb-12 54321 Mgmt Chan Jackie 123-4321 ABC4321 ChanJ ChanJ@fake.mail.us 0 ABC-ABC 123ABCD123 ABCD 1234 A1234 ABC12345A1 AB123AB 17-Feb-12 From the first line I would be trying to extract "Aragon Denvil L." and from the second "Mgmt Chan Jackie". Worst case scenario I could maybe get away with just extracting …

i have a function which is supposed to check if a number is a floating-point number. this is the structure of the function function isValidFloat( $string ){ if( !preg_match( "/^[0-9]+(.[0-9]+)?$/", $string ) ){ return false; } } for numbers such as 1 or 8 it's correctly validating but not for floating point numbers such 19.25. where am i missing it

Hello I'm want to convert string to array $str = "[cat=[0=php,script=[js]],id=4,foo=bar]"; how to write `preg pattern` for change `$str` to : $str = "[cat=[0=php,script=[js]]_-_id=4_-_foo=bar]"; If convert `,` to `_-_` I can convert this string to array by `foreach`, but i can't convert `,` to `_-_` in this string I'm want convert only `,id=4,foo=bar` to `_-_id=4_-_foo=bar`, No convert `[0=php,script=[js]]` to `[0=php_-_script=[js]]` have any idea?

In brief, I am puzzled as to why `~^[0-9]*?\|[0-9]*?\|.*?\|.*?\..*?\|2\|[0-9]\|.*?$~m` matches `1362526368|5|Corinne E. Fischer|fischer.jpg|3|3|FischerC@smh.ca|416-864-5320|1|2|3|4|5` Note the |3| after fischer.jpg when the pattern clearly has a \|2\| in that location. Now I understand that it must be the numbers at the end that are messing with the match but I don't really know how to fix it (the numbers at the end don't have to be numbers but can be any characters). This shouldn't be an issue later when I fill in proper data but I just want to know where I'm going wrong for future reference and for my peace of …

I am making a basic craigslist type website with a search function. There is a field where you can enter what you think the name of the product might be and my search function is supposed to find names of products that match. so for example a user can enter: "squat rack" "squatrack" "sqaut rack" "squat rac" "scuat rack" "squart rac" (you know, in case of a typo) and hopefull what will show up in the serach results is: "squat rack" "some other kind of rack" "squat machine" and things that are similar. I used "/<name of product>/" as my …

I have the following code. I wanted to determine if the value inputted in $cellno (from a textbox) are all digits (numbers), and if it's 11 numbers, and if its starting numbers are "09". One correct value example is 09345678910. It is all numbers, has 11 digits, and begins in 09. By the way, I got this error upon executing my code: Parse error: syntax error, unexpected '[' in C:\xampp\htdocs\GWS\cusdet.php on line 26 Please help!!! Super, super, duper newbie here. :( Thanks in advance!! <input id="cellno" type="text" placeholder = "Enter Cellphone Number" size = "20"> <?php $cellno = document.getElementById('cellno').value; $corcellno …

I wanted to validate a string with preg_match but after a lot of struggle I just used if($str[0]!='x'.... but just out of curiosity I wonna know how to do this using preg_match I'm getting a string as an input- the 1st char in the string must be % the 2nd char must be space the 3rd char must be a number and the rest can be anything (special chars/numbers/letters..)

I have a problem in a payment solution I have made. In this, I use ereg to extract a returned Transaction ID from the payment provider, and with PHP 5.3 this does not work anymore. The code used was: ereg('<TransactionId>(.+)</TransactionId>',$resultat_3,$c); I have tried to use this instead: (but it doesn't work) preg_match("/<TransactionId>(.+)<\/TransactionId>/",$resultat_3,$c); Does anybody have an idea what to do?

Hi all i want to check regular expression of a text field value i.e. it should not contain any '.,@' and other special characters except '_' and '-'. How can i write my rule in [code]preg_match()[/code] ?

I would love to know, if it's possible to get a specific data from a specific mysql table.. Let say on the table itself has a Varchar ... mixed of words and floats.. and then ... I want to pull only the float from the table using php... can it be done ??

Hi guys, I would like to validate some form input, and only allow the folowing: letters, numbers, /, - if(!preg_match("*[0-9A-Za-z,-,/]", $url_key)){ $erros[1] = '<small>Error submitting url key!</small>'; } Which is not working.. Its not the point only to allow one / or - But only letters, numbers and /- in the desired string length wanted by the user. I have not used preg_match, regex'es much before - so i hope someone can point this out. What is wrong in the way I begin the pattern, and end it etc etc? I Hope someone can make me a bit more clever …

Hello guyz, I'm glad I finally back here. I need help using the preg_match function. I am scraping url and I need to get the specific value from the html tags. Here is the string [I]<p><b>1,664</b> Referring IP addresses</p>[/I], I need to get [I][B]1,664[/B][/I] How can I achieve it using php?

So, I have this wordpress driven site, and I have a plugin written that runs when a post is viewed. The content of the post is loaded into $content. I also have a database of keywords and links to other posts on my site. I want to search the $content for any matches to any of the keywords, and replace the text with the the link associated with the matching keyword. BUT I can't just use str_replace(); because sometimes matching keywords also match image file names. Big problem. I'm kind of stumped, does an existing function allow for a simplistic …

Hi guys, It is working fine, and only allowing letters and numbers. I want to a feature, so that it has to be between 3-20 charachters/numbers long. [CODE] if (!preg_match("/^[A-Za-z0-9]+$/i", $_POST['brugernavn'])){ $dosomething = ''; } [/CODE] This is not working: [CODE] if (!preg_match("/^[A-Za-z0-9]{3-20}+$/i", $_POST['brugernavn'])) [/CODE]

Hi, Can someone lead me in the right direction on how to write a preg_match. I have username and password in the DB. And the username should be case sensitive, accordingly to whatever is in the db. And it should only be able to contain numbers and letters. I have this, but I havent used preg_match before, sp I am a little confused on how the syntax works and where to put what i want. [CODE] if(preg_match('/^[A-Z'.-]{2-20}$/i',$_POST['username'])){ $username = trim($_POST['username']); $username = mysqli_real_escape_string($connection, $username); } [/CODE] Hope somene can explain me the way this chinese is to be translated :-)

For example here is some code..... [CODE] preg_match_all("/<a(?:[^>]*)href=\"([^\"]*)\"(?:[^>]*)>(?:[^<]*)<\/a>/is", $stripped_file, $matches);[/CODE] What I don't get is all of those special characters? (?:[^>]*) How can I do this with the h1 tag, h2 tag, and h3 tag?

i have a field in my database with numbers like this....... ,27,,277,,4277,,677,,678,,6688,,8754,,123478, each number was updated (added) like this .. ,27, all numbers updated are unique, when i try to match ,27, i get ,27, ,277, ,4277, not just ,27, my code is like this... [code=php] $id = 27 $string = ",27,,277,,4277,,677,,678,,6688,,8754,,123478," $getid = preg_match("/$id/", $string); [/code] please help :)

Hello, I'm totally out of luck with creating a working patternt to match for my preg_match. What I would like to do is, create a pattern that will match sentenses in a bunch of text.. It should recognize a word that has a capital letter and take it as the start of sentese and then get all words till it hits . ? or !. so the patterns should contain A-Z a-z 0-9 , " ' and stop when it hits . ! or ? .. any help creating such pattern would be appriciated. Thanks, Dusan

Anyone have an idea what the regex would be for preg_split to split a string at a semicolon ([icode];[/icode]), but ignore any quoted (single or double) parts as well as ignore escaped ([icode]\;[/icode]) semicolons? I have tried to decipher this one and could not (regex not my strongpoint - YET) Herewith is a function I wrote that does this what I want. [code=php] //split string into characters and process... function split_at($input, $splitAt=";"){ $on=1; $j=0; $output[0]=""; for($i=0; $i<strlen($input); $i++) { //when a quote is reached then set $on switch off to ignore quoted part //untill another quote is reached then it …

Hello people, I'm trying to collect some data stored between <body> and </body> tags inside a string. Here's a piece of the code i'm using: [CODE] $regex = '/<body>(.*?)<\/body>/si'; preg_match($regex, $content, $content); $content = $content[0];[/CODE] This works perfect, except that it also includes the above mentioned tags. I would just like to grab the content in between those tags and store it. In other words, only store the (.*?) part of the regex. Anyone have an idea how to solve this? :)