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

Member Avatar
Member Avatar
+0 forum 4

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 …

Member Avatar
Member Avatar
+0 forum 2

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

Member Avatar
Member Avatar
+0 forum 3

Hi, is there any preg_match only allow `a-zA-Z0-9():[space]` ? Please help me =(

Member Avatar
Member Avatar
+0 forum 1

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?

Member Avatar
Member Avatar
+0 forum 5

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 …

Member Avatar
Member Avatar
+0 forum 2

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 …

Member Avatar
Member Avatar
+0 forum 25

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 …

Member Avatar
Member Avatar
+0 forum 2

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..)

Member Avatar
Member Avatar
+0 forum 2

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?

Member Avatar
Member Avatar
+0 forum 5

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] ?

Member Avatar
Member Avatar
+0 forum 5

Hi all, I am dealing a small issue. I am missing something silly :). My need is that I want the entire lines between <TABLE> </TABLE> with no modifications. [CODE]<?php $some_string = <<<STR <HR noShade size=2> <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR="" > <TR BGCOLOR="c1ffcc"> <TH ALIGN="LEFT" COLSPAN=22> <font face="Arial,Helvetica,Geneva,Swiss,Verdana" size="2" color="black">Baseline Comparison for Request Id: </font></TH> </TR> <TR BGCOLOR="lightblue"> <TH COLSPAN=1> </TH> </TABLE> </body> </html> STR; $match = preg_match('`<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR="" > (.*)</TABLE>`i', $some_string,$table); echo $match; print_r($table); [/CODE] But this code doesn't fetch me the desired output. Any help will be highly appreciated.

Member Avatar
Member Avatar
+0 forum 1

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 ??

Member Avatar
Member Avatar
+0 forum 8

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 …

Member Avatar
Member Avatar
+0 forum 6

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?

Member Avatar
Member Avatar
+0 forum 2

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 …

Member Avatar
Member Avatar
+0 forum 2

Hey, I have the following script... [CODE]if(!opendir($image_dir)){ echo info_msg("Ooops... This Album contains no images"); }else{ /* step one: read directory, make array of files */ if ($handle = opendir($image_dir)) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..' && preg_match("/t/",$file) && $file != '_notes' && $file != 'album_cover.jpg' && $file != 'preview.jpg' && $file != '.DS_Store') { $files[] = $file; } } closedir($handle); }[/CODE] However its not working how I want it to... I ONLY want it to count any files the END in t.jpg so I if I have 001.jpg 001t.jpg It …

Member Avatar
Member Avatar
+0 forum 3

Friends, I'm rushing towards deadline and I think that makes me do childish mistakes. Here I have validation that requires regex and each time I input valid expression preg_match returns false. It is long now I'm trying to spot error but I cannot! I have googled and AFAICS, things seems alright please help me spot the error. Thanks, Stefano [CODE]<?php $string = "37961/T.08";//valid ID, it is supposed to match $regex = '/^[0-9]{5,}/[a-zA-Z]\.[0-9]{2,}/'; if (preg_match($regex, $string)) { echo matched expression!'; } else { echo 'unmatched expression pattern';//comes here instead of valid regex! } ?>[/CODE]

Member Avatar
Member Avatar
+0 forum 4

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]

Member Avatar
Member Avatar
+0 forum 7

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 :-)

Member Avatar
Member Avatar
+0 forum 4

Hello all, I am trying to use more regex but I can't seem to get this to work. The aim is to check inputs for either [url, [link or <a href: [CODE] $islink = false; foreach($_POST as $k => $v){ if((preg_match("/[url|[link|<a href/i", $v)) > 0 ){ $islink = true; } } #gather data in sanitised variables $name = make_safe($_POST['name']); $feedback = make_safe($_POST['feedback']); $refer = make_safe($_POST['refer']); if($name && $feedback && !$islink){//process} [/CODE] The if keeps executing, Any help would be great

Member Avatar
Member Avatar
+0 forum 3

How can I get some part of $B to be only [B]auto[/B](The first word in $A[1])? [CODE] if(preg_match('/^(.*)">(.*)/',$A[1],$B) == 1) { die($B[1]); } [/CODE] $A[1] is.... [B]auto[/B]">auto</a>, <a href="automobile">automobile</a>, <a href="motorcar">motorcar</a>, <a href="machine">machine</a></div><div class=Rel><a hr .................................... /tr><tr><td><a href="zw

Member Avatar
Member Avatar
+0 forum 6

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?

Member Avatar
Member Avatar
+0 forum 3

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 :)

Member Avatar
Member Avatar
+0 forum 2

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

Member Avatar
Member Avatar
+0 forum 2

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 …

Member Avatar
Member Avatar
+0 forum 4

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? :)

Member Avatar
Member Avatar
+0 forum 1

The End.