Re: [PHP] Regexp help (simple)
Victor Spng Arthursson wrote: Have been playing around a bit with this code, but I can't get it to work with international characters For example, if I feed my function: function split_bokid($bokid) { if (preg_match('/^([a-z]{2,3})([0-9]{4,5}(\-[0-9]{1,2}){0,1})$/ i',$bokid,$m='')) { return $m; } else { return false; } } returns, with the following code: $test = split_bokid(123); I assume you mean: $test = split_bokid(12345); echo $test[1]; echo $test[2]; the values: 12345 So, is there any way I can set the encoding on the incoming values, which will come from url's and databases, so that they don't fuck up? I don't know. It works fine on my computer. The letters display correctly on the command line and even in Mozilla. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regexp help (simple)
2004-01-22 kl. 10.40 skrev Dagfinn Reiersl: I assume you mean: $test = split_bokid(12345); Yes! I don't know. It works fine on my computer. The letters display correctly on the command line and even in Mozilla. Hmmm try the following: http://adversus.no-ip.com/function_split_bokid.php?bokid=12345 Sincerely: Victor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regexp help (simple)
maybe this work: replace the special-characters first, eg.: $bokid = str_replace(å, _, $bokid); and replace them back after preg_match or try the preg_match with the hexcode of this special chars: \xhh character with hex code hh (http://ch2.php.net/manual/de/pcre.pattern.syntax.php) g. martin luethi Thu, 22 Jan 2004 15:43:19 +0100 Victor Spång Arthursson [EMAIL PROTECTED]: 2004-01-22 kl. 10.40 skrev Dagfinn Reiersøl: I assume you mean: $test = split_bokid(ääö12345); Yes! I don't know. It works fine on my computer. The letters display correctly on the command line and even in Mozilla. Hmmm? try the following: http://adversus.no-ip.com/function_split_bokid.php?bokid=åäö12345 Sincerely: Victor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regexp help (simple)
2004-01-20 kl. 10.41 skrev Dagfinn Reiersl: [EMAIL PROTECTED] wrote: $string = 'ab12345-1'; if (preg_match('/^([a-z]{2,3})([0-9]{4,5}(\-[0-9]{1,2}){0,1})$/i', $string, $m='')) { echo $m[1]; // - ab echo $m[2]; // - 12345-1 } g. martin luethi You can replace {0,1} with a question mark and [0-9] with \d (digit). Also, and I think this is not in the PHP documentation, you can use POSIX character classes inside the brackets. If you want to match alphabetical characters including the Swedish and various other international ones like or , you can use [:alpha:]. You may not need it in this example, but it's excellent for internationalized regex matching. if (preg_match('/^([[:alpha:]]{2,3})(\d{4,5}(\-\d{1,2})?)$/i', Have been playing around a bit with this code, but I can't get it to work with international characters For example, if I feed my function: function split_bokid($bokid) { if (preg_match('/^([a-z]{2,3})([0-9]{4,5}(\-[0-9]{1,2}){0,1})$/ i',$bokid,$m='')) { return $m; } else { return false; } } returns, with the following code: $test = split_bokid(123); echo $test[1]; echo $test[2]; the values: 12345 So, is there any way I can set the encoding on the incoming values, which will come from url's and databases, so that they don't fuck up? Sincerely, Victor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Regexp help (simple)
Hi! Anyone who could help me with this regexp problem? I want to verify that a string is made up of 2-3 letters, (a-z + åäö, A-Z + ÅÖÄ), directly followed by 4 or 5 digits, which could, but may not, be followed by a minus and one or two digits. Examples of valid strings: abc12345 ABC12345 abc1234 ABC12345-1 ABC12345-01 I would also like to split them into an array consisting of 2 elements; [0] = the first 2 or 3 letters [1] = the rest Example: string = ab12345 [0] = ab [1] = 12345 string = åäö1234-66 [0] = åäö [1] = 1234-66 Lots of thanks in advance, sincerely Victor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regexp help (simple)
$string = 'ab12345-1'; if (preg_match('/^([a-zåäö]{2,3})([0-9]{4,5}(\-[0-9]{1,2}){0,1})$/i', $string, $m='')) { echo $m[1]; // - ab echo $m[2]; // - 12345-1 } g. martin luethi Tue, 20 Jan 2004 09:59:37 +0100 Victor Spång Arthursson [EMAIL PROTECTED]: Hi! Anyone who could help me with this regexp problem? I want to verify that a string is made up of 2-3 letters, (a-z + åäö, A-Z + ÅÖÄ), directly followed by 4 or 5 digits, which could, but may not, be followed by a minus and one or two digits. Examples of valid strings: abc12345 ABC12345 abc1234 ABC12345-1 ABC12345-01 I would also like to split them into an array consisting of 2 elements; [0] = the first 2 or 3 letters [1] = the rest Example: string = ab12345 [0] = ab [1] = 12345 string = åäö1234-66 [0] = åäö [1] = 1234-66 Lots of thanks in advance, sincerely Victor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regexp help (simple)
[EMAIL PROTECTED] wrote: $string = 'ab12345-1'; if (preg_match('/^([a-zåäö]{2,3})([0-9]{4,5}(\-[0-9]{1,2}){0,1})$/i', $string, $m='')) { echo $m[1]; // - ab echo $m[2]; // - 12345-1 } g. martin luethi You can replace {0,1} with a question mark and [0-9] with \d (digit). Also, and I think this is not in the PHP documentation, you can use POSIX character classes inside the brackets. If you want to match alphabetical characters including the Swedish and various other international ones like æ or ü, you can use [:alpha:]. You may not need it in this example, but it's excellent for internationalized regex matching. if (preg_match('/^([[:alpha:]]{2,3})(\d{4,5}(\-\d{1,2})?)$/i', Tue, 20 Jan 2004 09:59:37 +0100 Victor Spång Arthursson [EMAIL PROTECTED]: Hi! Anyone who could help me with this regexp problem? I want to verify that a string is made up of 2-3 letters, (a-z + åäö, A-Z + ÅÖÄ), directly followed by 4 or 5 digits, which could, but may not, be followed by a minus and one or two digits. Examples of valid strings: abc12345 ABC12345 abc1234 ABC12345-1 ABC12345-01 I would also like to split them into an array consisting of 2 elements; [0] = the first 2 or 3 letters [1] = the rest Example: string = ab12345 [0] = ab [1] = 12345 string = åäö1234-66 [0] = åäö [1] = 1234-66 Lots of thanks in advance, sincerely Victor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php