I have a few variabes, which are usually abbreviated. Here's an example. $a="Inter M"; $b="FC Internazionale Milano"; Obviously, $a != $b. Suppose [-] means anystring. We do: $a=str_replace(" ", "[-]", $a); // Inter[-]M $a="[-]". $a ."[-]"; // [-]Inter[-]M[-] Then $a does equal $b, because [-] fills in the rest of the missing components. Can someone tell me how this is done in regular expressions, because the above is obviously not php syntax but rather something that i wrote to demonstrate. Thx, Erind
Ellaborate?, do you mean this: <?php $a = "Inter M"; $b = "FC Internazionale Milano"; $a = preg_quote($a); $a = str_replace(" ", ".+?", $a); if (preg_match('~'.$a.'~i', $b)){ echo "{$a} == {$b}"; } ?> PHP:
Heres a bit more info. The abbreviated version of the variable is always found in the full version. The abbreviated version usually misses parts or has shortened versions. Here are some examples that would be matched. $a=$b Inter= FC Internazionale Milano Inter M= FC Internazionale Milano Man Utd=Manchester Utd Bayern=Bayern Munchen G. Bistra=Gloria Bistra As you can see the example I said works in every case. Just the last case, G. Bistra, has a period and space as a separator. Bottom Line: Get rid of irregular characters and spaces, and match them with anything as long as the rest matches. Thx
There are different matches, but the idea/format is always right, like I demonstrated. Match alphanumerical values, and guess the rest. 99.9% it will be correct. That .1 percent I will take care of manually, lol. Dan was on the right track just needs slight tweeking.
Yessir I can't come online. I am at work. Here's what's up: The match is recorderd, everything is great. I have another xml source that checks for wins/losses. This source houwever uses the full names of each team instead. So sometimes they match, sometimes they dont. When they don't its the case like I said where I have an abbreviated version of the team name. BTW, that script turned out to be more than 100 php files, and 4 js files on top of the css/html. I thought it was easy to start with...
You could try the folllowing (but this would match if any occurence within $a is within $b): if (stristr($b, $a)){ //matched.. } PHP: Perhaps Jay could give a better response as im not a regex guru. and regarding the 100 php files lol - I believe i only gave you 1 php file (which was around 30 lines using DOM), not sure why your having to have 100 files - its what happens when you use php uneffectively.
Well, what happened was I thought I needed to read xml and then process it. well not so much. read xml, select data using ajax, store data using php, check data, confirm data against xml again, user system, admin panel, omggggg. I have literally been working on it since back when was it, february? not consistantly but at least 5+ hours a week if (stristr($b, $a)){ //matched.. } PHP: That would match, Inter in Internazionale, but not Man Utd in Manchester Utd...
$a="Inter M"; $b="FC Internazionale Milano"; // Remove all the non-alphabetic/space characters $stripped = preg_replace('/[^a-z\s]+/i', '', $a); //Split the string into single words $words = explode(' ', $stripped); //Add .+ between words and .* either side of them and create a regex $regex = '/.*'.implode('.+', $words).'.*/i'; //Test regex if(preg_match($regex, $b)) { echo 'MATCH'; }else{ echo 'NO MATCH'; } PHP: Try that