[PHP] Regexp help second
Hi! Last help about regexp solve my problem, but I have another one. I've made some regexp but it does not work always Let say I have some strings 1) this is some domain.com test 2) domain.com I can make this work either for first example of fo second, but not for both. What I want is replace of domain.com to get this is dome domain.com domain com test so replace should be \1 \2 \3 so for second example I did /((.+)\.{1}(.+))/ How can I extend this to work in both. regards Uros -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regexp help second
You could maybe cheat and add an X at the beginning and end of the string before your Regex, then you will have: X\1 \2 \3X and you can strip off the initial X from \1 and the trailing X from \3 There's probably some fancy Regexp way to do it though. Uroš Gruber wrote: Hi! Last help about regexp solve my problem, but I have another one. I've made some regexp but it does not work always Let say I have some strings 1) this is some domain.com test 2) domain.com I can make this work either for first example of fo second, but not for both. What I want is replace of domain.com to get this is dome domain.com domain com test so replace should be \1 \2 \3 so for second example I did /((.+)\.{1}(.+))/ How can I extend this to work in both. regards Uros -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regexp help second
On Thu, 06 Jan 2005 13:50:58 +0100, Uro Gruber [EMAIL PROTECTED] wrote: 1) this is some domain.com test 2) domain.com I can make this work either for first example of fo second, but not for both. What I want is replace of domain.com to get this is dome domain.com domain com test so replace should be \1 \2 \3 so for second example I did /((.+)\.{1}(.+))/ How can I extend this to work in both. Can you explain in a little more detail what you're trying to replace domain.com with? I'm having trouble understanding your intentions. A regular expression like: /([\w-]+)\.([\w-]+)/ should be able to grab strings like domain.com in any type of string (I'm using the preg_replace function). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Regexp help
What would the regex look like to accept *any* character for a value but the total length of the value can be no greater than 50 characters. The regex I am trying to use is as follows ^[\d\D\w\W\s\S.]{0,50}$ but it doesn't appear to be working... Any ideas? thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regexp help
From: Chris Boget [EMAIL PROTECTED] Subject: [PHP] Regexp help What would the regex look like to accept *any* character for a value but the total length of the value can be no greater than 50 characters. The regex I am trying to use is as follows ^[\d\D\w\W\s\S.]{0,50}$ but it doesn't appear to be working... Any ideas? Well, strlen() would be more appropriate than a regular expression to check for the length of a string. Wouldn't /^.{0,50}$/ work, though? ---John Holmes... (back to Cisco training... ;) UCCASS - PHP Survey System http://www.bigredspark.com/survey.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
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
[PHP] regexp help please!
I'm writing a PHP script inspired by smartypants and textile (but for PHP), which among other things does smart quoting. However, I want to avoid smart quotes inside all tags (all quotes inside and ). Since there are numerous functions accounting for numerous special cases, AND the fact that there will be very few tags with quotes (a is all so far), I'm thinking it's be easiest to go back through the converted text and replace all converted smart characters back to stupid ones something like $out = preg_replace(/(.*?)[#8220;|#8221;](.*?)/,\\1\\\2,$in); // doubles $out = preg_replace(/(.*?)[#8217;|#821;](.*?)/,\\1'\\2,$in); // singles would be nice, but it isn't working, and I think this is stretching my skills in preg's waaay too far. simularly, I'd like to preserver / de-convert any text contained with pre/pre tags Any hints would be great! Justin French -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] regexp help...
Hi all, I have a string that for all practical purposes should probably be a list (array). I need one line from the string and need to send the rest to /dev/null. The string starts: HTTP/1.1 200 OK Date: Tue, 22 Jul 2003 01:34:12 GMT Server: Apache/1.3.27 (Unix) mod_jk/1.1.0 mod_ssl/2.8.12 OpenSSL/0.9.6g Set-Cookie: JSESSIONID=mngtpma6i1;Path=/Interface Connection: close Content-Type: text/html;charset=ISO-8859-1 ?xml version=1.0? blah blah blah /shipment The String ends on the line above (white space line). If I'm not mistaken the blank lines are actually a combo of unix and dos line returns. any help is much appreciated. thanks,
Re: [PHP] regexp help...
I guess I should point out that the line i want is the XML line '?xml..' On Monday, July 21, 2003, at 11:44 AM, Doug La Farge wrote: Hi all, I have a string that for all practical purposes should probably be a list (array). I need one line from the string and need to send the rest to /dev/null. The string starts: HTTP/1.1 200 OK Date: Tue, 22 Jul 2003 01:34:12 GMT Server: Apache/1.3.27 (Unix) mod_jk/1.1.0 mod_ssl/2.8.12 OpenSSL/0.9.6g Set-Cookie: JSESSIONID=mngtpma6i1;Path=/Interface Connection: close Content-Type: text/html;charset=ISO-8859-1 ?xml version=1.0? blah blah blah /shipment The String ends on the line above (white space line). If I'm not mistaken the blank lines are actually a combo of unix and dos line returns. any help is much appreciated. thanks, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] regexp help wanted
Hi folks, I just got nuts by trying to find a regexp for use with preg_replace to achive the following: remove all br / which are in the text between a pre and a /pre Tag. So, I want no br between these tags. Any ideas or quick help? thanks in advance, Thomas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RegExp Help: [:cntrl:] not working
I'm trying to preg_split() text between page. I used the following but can't get the regular expression to work: $content = blah blah page blah blah blah; $paged = preg_split( [[:cntrl:]*]page[[:cntrl:]*], $content ); I also tried the following... $content = blah blah page blah blah blah; $paged = preg_split( [:cntrl:]page[:cntrl:], $content ); ...and... $content = blah blah page blah blah blah; $paged = preg_split( [[:cntrl:]]page[[:cntrl:]], $content ); But none of these work. Can someone tell me what's wrong? I just want to split the text on page and include any line feeds that may have been put in before or after the page text. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RegExp Help: [:cntrl:] not working
On Thu, Jul 11, 2002 at 06:41:28PM -0400, Monty wrote: I'm trying to preg_split() text between page. I used the following but can't get the regular expression to work: $content = blah blah page blah blah blah; $paged = preg_split( [[:cntrl:]*]page[[:cntrl:]*], $content ); The * needs to be after the character class, ie [[:cntrl:]]*. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RegExp Help: [:cntrl:] not working
The * needs to be after the character class, ie [[:cntrl:]]*. --Dan Thanks Dan. But, removing the asterisk or putting it after the character class doesn't work either for some reason. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RegExp Help: [:cntrl:] not working
On Thu, Jul 11, 2002 at 07:33:59PM -0400, Monty wrote: Thanks Dan. But, removing the asterisk or putting it after the character class doesn't work either for some reason. Have you tried [[:space:]]* instead? That'll pull in line breaks, tabs and spaces. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RegExp Help: [:cntrl:] not working
Have you tried [[:space:]]* instead? That'll pull in line breaks, tabs and spaces. --Dan I just tried it, but, still can't make this work. Also, I'm getting different results between explode() and preg_split(), is that normal? Here's what I'm trying: $content = blah blah page_break blah blah blah blah; $contentpage = preg_split([[:space:]]*page_break[[:space:]]*, $content); But I just get a PHP error: Warning: Unknown modifier '*' in testme.php If I try this: $content = blah blah page_break blah blah blah blah; $contentpage = preg_split([[:space:]]page_break[[:space:]], $content); I get this PHP error: Warning: Unknown modifier 'p' in testme.php I'm not sure what I'm doing wrong with the reg exp, but, it won't even parse. Both expressions above used with explode() only produce empty array variables, as though it's stripping out everything. What am I doing wrong? Monty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RegExp Help: [:cntrl:] not working
On Thu, Jul 11, 2002 at 11:24:34PM -0400, Monty wrote: $contentpage = preg_split([[:space:]]*page_break[[:space:]]*, $content); DOH! It's preg!!! [[:space:]] is for ereg. Use \s. I don't know why I didn't notice sooner. Do this: '/\s*page_break\s*/' --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RegExp Help: [:cntrl:] not working
Yes! That was it! Thank you so much. I actually thought preg and ereg were interchangeable, so, I'm glad you pointed out the difference for reg expressions. Can you tell me what the open and closing slashes / are for inside the quotes? Is it equivalent to [ and ] for ereg? Monty DOH! It's preg!!! [[:space:]] is for ereg. Use \s. I don't know why I didn't notice sooner. Do this: '/\s*page_break\s*/' --Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RegExp Help: [:cntrl:] not working
On Fri, Jul 12, 2002 at 12:08:36AM -0400, Monty wrote: expressions. Can you tell me what the open and closing slashes / are for inside the quotes? Is it equivalent to [ and ] for ereg? They are delimiters. Other characters can be used, but / is the standard. --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RegExp help..
Try this: $ ereg("^([0-9]{2})[0-9]{2}([0-9]{2}).*", $var, $hits) if ($hits[1] == themonth $hits[2] == theyear) { do_the_stuff } What it does is that it puts the first two digitst into $hits[1], skips the two nextcoming digits and finally puts the next two numbers into $hits[2] /Fredrik Ursprungligt meddelande John Vanderbeck [EMAIL PROTECTED] skrev 2001-03-12, kl. 02:40:25 angende mnet [PHP] RegExp help..: I really wish I could figure these darn things out :) I have a task I need to do, and i'm certain I could do this easily with a regexp.. I have a file name in the format MMDDYY-*.txt...I need to parse it to determine if the month and year matches a specified month and year. Day is irrelevant Can any of your regexp wizards help me? Thanks! - John Vanderbeck - Admin, GameDesign -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]