[PHP] Re: ereg question/prob...

2004-07-15 Thread Tim Van Wassenhove
In article [EMAIL PROTECTED], Bruce wrote:
 $file = .txt;
 
 ereg((\.)([a-z0-9]{3,5})$, $file, $regs);
 echo  ww = .$regs. brbr;
 
 
 i'm trying to figure out how to get the portion of the regex that's the
 extension of the file. my understanding of the docs, says that the
 extension should be in the $reg array
 
 any ideas/comments on where my mistake is would be appreciated...

Will it work with 123.123.txt ?

If you have a look at the file functions in the manual, you'll find much
better solutions like pathinfo();


-- 
Tim Van Wassenhove http://home.mysth.be/~timvw

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: ereg question/prob...

2004-07-15 Thread Red Wingate
$regs is an array not a string !
try print_r or var_dump to determine $regexp's content
Tim Van Wassenhove wrote:
In article [EMAIL PROTECTED], Bruce wrote:
$file = .txt;
ereg((\.)([a-z0-9]{3,5})$, $file, $regs);
echo  ww = .$regs. brbr;
i'm trying to figure out how to get the portion of the regex that's the
extension of the file. my understanding of the docs, says that the
extension should be in the $reg array
any ideas/comments on where my mistake is would be appreciated...

Will it work with 123.123.txt ?
If you have a look at the file functions in the manual, you'll find much
better solutions like pathinfo();

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Re: Ereg problems

2004-03-26 Thread Jeff McKeon
 -Original Message-
 From: Curt Zirzow [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, March 25, 2004 6:55 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Re: Ereg problems
 
 
 On Thu, 25 Mar 2004 18:31:02 -0500, Jeff McKeon 
 [EMAIL PROTECTED] 
 wrote:
 
  Having some problems with ereg()
 
  [begin code]
 
  $string=Credit adjusted: $-1.32 to $48.68
 
  ereg(([\\$(\\$-)][0-9]+\.[0-9]+),$data[2],$found);
  
  While(list($index,$hits)=each($found))
  {
  echo $index , $hitsbr;
  }
  [end code]
 
 you assigned $string but used $data[2]?
 

whoops, that was a leftover from the actual app that was parsing
a field pulled from a database query.  Forgot to correct that when I
posted.

 
 I would suggest using pcre instead of Posix:
 
 preg_match_all('($-?[0-9]+\.[0-9]+)', $string, $found); 
 print_r($found);
 

That produces:

Array ( [0] = Array ( ) ) 0 , Array

 
 Curt.
 
 -- 
 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] Re: Ereg problems

2004-03-26 Thread Curt Zirzow
* Thus wrote Jeff McKeon ([EMAIL PROTECTED]):
 
  
  preg_match_all('($-?[0-9]+\.[0-9]+)', $string, $found); 
  print_r($found);
  
 
 That produces:
 
 Array ( [0] = Array ( ) ) 0 , Array

Sorry that should be:
  preg_match_all('/(\$-?[0-9]+\.[0-9]+)/', $string, $found); 


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Ereg problems

2004-03-25 Thread Curt Zirzow
On Thu, 25 Mar 2004 18:31:02 -0500, Jeff McKeon [EMAIL PROTECTED] 
wrote:

Having some problems with ereg()

[begin code]

$string=Credit adjusted: $-1.32 to $48.68

ereg(([\\$(\\$-)][0-9]+\.[0-9]+),$data[2],$found);

While(list($index,$hits)=each($found))
{
echo $index , $hitsbr;
}
[end code]
you assigned $string but used $data[2]?

I would suggest using pcre instead of Posix:

preg_match_all('($-?[0-9]+\.[0-9]+)', $string, $found);
print_r($found);
Curt.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: ereg is failing on this simple test

2003-12-12 Thread Mike
it works if you remove the last $ from the expression, also I think the 
. needs escaping

unless you have a special reason, use preeg_* as it is supposed to be 
quicker

Mike

Manuel Ochoa wrote:
Why is this test failing?
 
$data = A Simple test.;
If (ereg(^[a-zA-Z0-9\s.\-_']+$, $data)) {
  echo Valid text;
}
else {
  echo Not valid text;
}
 
I'm running PHP 4.34 on a windows pc. This function is new to me, any help would be appreciated.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: ereg

2003-09-12 Thread Dave Dash
I think this is a lot more complicated than somethign a simple regular
expression can handle.

You would need to do soemthign that reads the entire file, up until the
first occurrence of your '//'

and in the meantime do a count that checks to make sure all the quotes are
closed.

I'd be interested to see what you come up with... although I'm sure just
borrowing some syntax highlighting code.

-dd

Alexander Sundli [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I use this expression to remove oneline comments:
 iereg_replace(//([^\n]*)\n,'',$code);

 I need to make a check if this expression is inside a string. If it is,
its
 not a comment.

 I think it has something to do with context..

 Anyone who could help me?

 thanx

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: ereg() can't recognize characters such as èéêë...

2003-07-29 Thread DvDmanDT
Use preg_*() functions then? Not that I think they would be much better
but...

-- 
// DvDmanDT
MSN: [EMAIL PROTECTED]
Mail: [EMAIL PROTECTED]
Ivo Fokkema [EMAIL PROTECTED] skrev i meddelandet
news:[EMAIL PROTECTED]
 Hi list,

 I read through the manual and tried to find something on google, but I
 didn't come to anything useful.

 It seems that the ereg()-family (I tried ereg(), eregi() and
ereg_replace())
 can't recognize any special characters such as èéêë etc. I tested this :

 ?php
 print

(ereg([[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:pri
 nt:][:punct:][:space:][:upper:][:xdigit:]],é));
 ?

 and it returned a blank screen. When I fill in a regular character such as
 'e' or a slash or whatever, it returns 1. I ran into this when I tested a
 script which should replace '{PMID[PubMed ID number]:[First author's
name]}
 into a link to the article online. For instance, {PMID12632325:Flanigan}
 results in A

href=http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieveamp;db=PubM
 edamp;dopt=Abstractamp;list_uids=12632325
target=_blankFlanigan/A.

 This worked all fine, until an author's name was Müller. Then my
 ereg_replace() failed (below). Any ideas?

 ?php
 $val = ereg_replace({PMID([[:alnum:]. _-]*):([[:alnum:]. _-]*)}, A

href=\http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieveamp;db=Pub
 Medamp;dopt=Abstractamp;list_uids=\\1\
 target=\_blank\\\2/A,{PMID11519736:Müller});
 print ($val);
 ?

 TIA!

 --
 [Win2000 | Apache/1.3.23]
 [PHP/4.2.3 | MySQL/3.23.53]

 Ivo Fokkema
 PHP  MySQL programmer
 Leiden University Medical Centre
 Netherlands





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: ereg() can't recognize characters... [SOLVED]

2003-07-29 Thread Ivo Fokkema
Well d*mn, why didn't I think of this... It seems to work now! Thanks!

I'm not such an expert on the Perl compatible regexp's so I rarely use
them... Yet another reason to start using them though...

Thanx!

Dvdmandt [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Use preg_*() functions then? Not that I think they would be much better
 but...

 --
 // DvDmanDT
 MSN: [EMAIL PROTECTED]
 Mail: [EMAIL PROTECTED]
 Ivo Fokkema [EMAIL PROTECTED] skrev i meddelandet
 news:[EMAIL PROTECTED]
  Hi list,
 
  I read through the manual and tried to find something on google, but I
  didn't come to anything useful.
 
  It seems that the ereg()-family (I tried ereg(), eregi() and
 ereg_replace())
  can't recognize any special characters such as èéêë etc. I tested this :
 
  ?php
  print
 

(ereg([[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:pri
  nt:][:punct:][:space:][:upper:][:xdigit:]],é));
  ?
 
  and it returned a blank screen. When I fill in a regular character such
as
  'e' or a slash or whatever, it returns 1. I ran into this when I tested
a
  script which should replace '{PMID[PubMed ID number]:[First author's
 name]}
  into a link to the article online. For instance,
{PMID12632325:Flanigan}
  results in A
 

href=http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieveamp;db=PubM
  edamp;dopt=Abstractamp;list_uids=12632325
 target=_blankFlanigan/A.
 
  This worked all fine, until an author's name was Müller. Then my
  ereg_replace() failed (below). Any ideas?
 
  ?php
  $val = ereg_replace({PMID([[:alnum:]. _-]*):([[:alnum:]. _-]*)}, A
 

href=\http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieveamp;db=Pub
  Medamp;dopt=Abstractamp;list_uids=\\1\
  target=\_blank\\\2/A,{PMID11519736:Müller});
  print ($val);
  ?
 
  TIA!
 
  --
  [Win2000 | Apache/1.3.23]
  [PHP/4.2.3 | MySQL/3.23.53]
 
  Ivo Fokkema
  PHP  MySQL programmer
  Leiden University Medical Centre
  Netherlands
 
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: ereg() can't recognize characters... [SOLVED]

2003-07-29 Thread DvDmanDT
What? Did it seriously help?
You might be intrested in this regex then:

preg_replace(#[a-z0-9\-\._îÎèéüÜÉÈáàÁÀäÄåÅöÖ]+#i,'a href=YOU
FORMAT',$VARIABLE);
// Should hit most chars you want...

-- 
// DvDmanDT
MSN: [EMAIL PROTECTED]
Mail: [EMAIL PROTECTED]
Ivo Fokkema [EMAIL PROTECTED] skrev i meddelandet
news:[EMAIL PROTECTED]
 Well d*mn, why didn't I think of this... It seems to work now! Thanks!

 I'm not such an expert on the Perl compatible regexp's so I rarely use
 them... Yet another reason to start using them though...

 Thanx!

 Dvdmandt [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Use preg_*() functions then? Not that I think they would be much better
  but...
 
  --
  // DvDmanDT
  MSN: [EMAIL PROTECTED]
  Mail: [EMAIL PROTECTED]
  Ivo Fokkema [EMAIL PROTECTED] skrev i meddelandet
  news:[EMAIL PROTECTED]
   Hi list,
  
   I read through the manual and tried to find something on google, but I
   didn't come to anything useful.
  
   It seems that the ereg()-family (I tried ereg(), eregi() and
  ereg_replace())
   can't recognize any special characters such as èéêë etc. I tested this
:
  
   ?php
   print
  
 

(ereg([[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:pri
   nt:][:punct:][:space:][:upper:][:xdigit:]],é));
   ?
  
   and it returned a blank screen. When I fill in a regular character
such
 as
   'e' or a slash or whatever, it returns 1. I ran into this when I
tested
 a
   script which should replace '{PMID[PubMed ID number]:[First author's
  name]}
   into a link to the article online. For instance,
 {PMID12632325:Flanigan}
   results in A
  
 

href=http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieveamp;db=PubM
   edamp;dopt=Abstractamp;list_uids=12632325
  target=_blankFlanigan/A.
  
   This worked all fine, until an author's name was Müller. Then my
   ereg_replace() failed (below). Any ideas?
  
   ?php
   $val = ereg_replace({PMID([[:alnum:]. _-]*):([[:alnum:]. _-]*)}, A
  
 

href=\http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieveamp;db=Pub
   Medamp;dopt=Abstractamp;list_uids=\\1\
   target=\_blank\\\2/A,{PMID11519736:Müller});
   print ($val);
   ?
  
   TIA!
  
   --
   [Win2000 | Apache/1.3.23]
   [PHP/4.2.3 | MySQL/3.23.53]
  
   Ivo Fokkema
   PHP  MySQL programmer
   Leiden University Medical Centre
   Netherlands
  
  
 
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: ereg() can't recognize characters... [SOLVED]

2003-07-29 Thread DvDmanDT
Also... You know, there's a (.*?) command as well.. Might work just about
perfect in your situation...

-- 
// DvDmanDT
MSN: [EMAIL PROTECTED]
Mail: [EMAIL PROTECTED]
Ivo Fokkema [EMAIL PROTECTED] skrev i meddelandet
news:[EMAIL PROTECTED]
 Well d*mn, why didn't I think of this... It seems to work now! Thanks!

 I'm not such an expert on the Perl compatible regexp's so I rarely use
 them... Yet another reason to start using them though...

 Thanx!

 Dvdmandt [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Use preg_*() functions then? Not that I think they would be much better
  but...
 
  --
  // DvDmanDT
  MSN: [EMAIL PROTECTED]
  Mail: [EMAIL PROTECTED]
  Ivo Fokkema [EMAIL PROTECTED] skrev i meddelandet
  news:[EMAIL PROTECTED]
   Hi list,
  
   I read through the manual and tried to find something on google, but I
   didn't come to anything useful.
  
   It seems that the ereg()-family (I tried ereg(), eregi() and
  ereg_replace())
   can't recognize any special characters such as èéêë etc. I tested this
:
  
   ?php
   print
  
 

(ereg([[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:pri
   nt:][:punct:][:space:][:upper:][:xdigit:]],é));
   ?
  
   and it returned a blank screen. When I fill in a regular character
such
 as
   'e' or a slash or whatever, it returns 1. I ran into this when I
tested
 a
   script which should replace '{PMID[PubMed ID number]:[First author's
  name]}
   into a link to the article online. For instance,
 {PMID12632325:Flanigan}
   results in A
  
 

href=http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieveamp;db=PubM
   edamp;dopt=Abstractamp;list_uids=12632325
  target=_blankFlanigan/A.
  
   This worked all fine, until an author's name was Müller. Then my
   ereg_replace() failed (below). Any ideas?
  
   ?php
   $val = ereg_replace({PMID([[:alnum:]. _-]*):([[:alnum:]. _-]*)}, A
  
 

href=\http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieveamp;db=Pub
   Medamp;dopt=Abstractamp;list_uids=\\1\
   target=\_blank\\\2/A,{PMID11519736:Müller});
   print ($val);
   ?
  
   TIA!
  
   --
   [Win2000 | Apache/1.3.23]
   [PHP/4.2.3 | MySQL/3.23.53]
  
   Ivo Fokkema
   PHP  MySQL programmer
   Leiden University Medical Centre
   Netherlands
  
  
 
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: ereg() can't recognize characters... [SOLVED]

2003-07-29 Thread Ivo Fokkema
Well, I tried that first, but it failed when some user whould list multiple
references. The ereg_replace would then take the two references as one.
{PMID11519736:Müller}, {PMID8789442:Milasin} would result in a link to
Müller named Müller}, {PMID8789442:Milasin instead of two separate
links...

Thanks again!

Ivo

Dvdmandt [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Also... You know, there's a (.*?) command as well.. Might work just about
 perfect in your situation...

 --
 // DvDmanDT
 MSN: [EMAIL PROTECTED]
 Mail: [EMAIL PROTECTED]
 Ivo Fokkema [EMAIL PROTECTED] skrev i meddelandet
 news:[EMAIL PROTECTED]
  Well d*mn, why didn't I think of this... It seems to work now! Thanks!
 
  I'm not such an expert on the Perl compatible regexp's so I rarely use
  them... Yet another reason to start using them though...
 
  Thanx!
 
  Dvdmandt [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
   Use preg_*() functions then? Not that I think they would be much
better
   but...
  
   --
   // DvDmanDT
   MSN: [EMAIL PROTECTED]
   Mail: [EMAIL PROTECTED]
   Ivo Fokkema [EMAIL PROTECTED] skrev i meddelandet
   news:[EMAIL PROTECTED]
Hi list,
   
I read through the manual and tried to find something on google, but
I
didn't come to anything useful.
   
It seems that the ereg()-family (I tried ereg(), eregi() and
   ereg_replace())
can't recognize any special characters such as èéêë etc. I tested
this
 :
   
?php
print
   
  
 

(ereg([[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:pri
nt:][:punct:][:space:][:upper:][:xdigit:]],é));
?
   
and it returned a blank screen. When I fill in a regular character
 such
  as
'e' or a slash or whatever, it returns 1. I ran into this when I
 tested
  a
script which should replace '{PMID[PubMed ID number]:[First author's
   name]}
into a link to the article online. For instance,
  {PMID12632325:Flanigan}
results in A
   
  
 

href=http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieveamp;db=PubM
edamp;dopt=Abstractamp;list_uids=12632325
   target=_blankFlanigan/A.
   
This worked all fine, until an author's name was Müller. Then my
ereg_replace() failed (below). Any ideas?
   
?php
$val = ereg_replace({PMID([[:alnum:]. _-]*):([[:alnum:]. _-]*)},
A
   
  
 

href=\http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieveamp;db=Pub
Medamp;dopt=Abstractamp;list_uids=\\1\
target=\_blank\\\2/A,{PMID11519736:Müller});
print ($val);
?
   
TIA!
   
--
[Win2000 | Apache/1.3.23]
[PHP/4.2.3 | MySQL/3.23.53]
   
Ivo Fokkema
PHP  MySQL programmer
Leiden University Medical Centre
Netherlands
   
   
  
  
 
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: ereg() can't recognize characters... [SOLVED]

2003-07-29 Thread Curt Zirzow
* Thus wrote Ivo Fokkema ([EMAIL PROTECTED]):
 Well d*mn, why didn't I think of this... It seems to work now! Thanks!
 
 I'm not such an expert on the Perl compatible regexp's so I rarely use
 them... Yet another reason to start using them though...

Its a good thing to learn perl regular expressions, besides being
more powerful they are usually much faster.  The only reason not to
use them before was because they had to be compiled special in php
in earlier versions.  And sometimes its hard to get hosting company
to recompile a custom php version for you.

Now PREC is compiled by default.

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: ereg() can't recognize characters... [SOLVED]

2003-07-29 Thread DvDmanDT
Notice the ?... The ? after the * is at least supposed to stop that
problem... So preg_replace(#\{(.*?),(.*?)\}#,a
href=\script.php?id=\\1\\\2/a,$whatever); should do what you want...
:p

-- 
// DvDmanDT
MSN: [EMAIL PROTECTED]
Mail: [EMAIL PROTECTED]
Ivo Fokkema [EMAIL PROTECTED] skrev i meddelandet
news:[EMAIL PROTECTED]
 Well, I tried that first, but it failed when some user whould list
multiple
 references. The ereg_replace would then take the two references as one.
 {PMID11519736:Müller}, {PMID8789442:Milasin} would result in a link to
 Müller named Müller}, {PMID8789442:Milasin instead of two separate
 links...

 Thanks again!

 Ivo

 Dvdmandt [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Also... You know, there's a (.*?) command as well.. Might work just
about
  perfect in your situation...
 
  --
  // DvDmanDT
  MSN: [EMAIL PROTECTED]
  Mail: [EMAIL PROTECTED]
  Ivo Fokkema [EMAIL PROTECTED] skrev i meddelandet
  news:[EMAIL PROTECTED]
   Well d*mn, why didn't I think of this... It seems to work now! Thanks!
  
   I'm not such an expert on the Perl compatible regexp's so I rarely use
   them... Yet another reason to start using them though...
  
   Thanx!
  
   Dvdmandt [EMAIL PROTECTED] wrote in message
   news:[EMAIL PROTECTED]
Use preg_*() functions then? Not that I think they would be much
 better
but...
   
--
// DvDmanDT
MSN: [EMAIL PROTECTED]
Mail: [EMAIL PROTECTED]
Ivo Fokkema [EMAIL PROTECTED] skrev i meddelandet
news:[EMAIL PROTECTED]
 Hi list,

 I read through the manual and tried to find something on google,
but
 I
 didn't come to anything useful.

 It seems that the ereg()-family (I tried ereg(), eregi() and
ereg_replace())
 can't recognize any special characters such as èéêë etc. I tested
 this
  :

 ?php
 print

   
  
 

(ereg([[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:pri
 nt:][:punct:][:space:][:upper:][:xdigit:]],é));
 ?

 and it returned a blank screen. When I fill in a regular character
  such
   as
 'e' or a slash or whatever, it returns 1. I ran into this when I
  tested
   a
 script which should replace '{PMID[PubMed ID number]:[First
author's
name]}
 into a link to the article online. For instance,
   {PMID12632325:Flanigan}
 results in A

   
  
 

href=http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieveamp;db=PubM
 edamp;dopt=Abstractamp;list_uids=12632325
target=_blankFlanigan/A.

 This worked all fine, until an author's name was Müller. Then my
 ereg_replace() failed (below). Any ideas?

 ?php
 $val = ereg_replace({PMID([[:alnum:]. _-]*):([[:alnum:]. _-]*)},
 A

   
  
 

href=\http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieveamp;db=Pub
 Medamp;dopt=Abstractamp;list_uids=\\1\
 target=\_blank\\\2/A,{PMID11519736:Müller});
 print ($val);
 ?

 TIA!

 --
 [Win2000 | Apache/1.3.23]
 [PHP/4.2.3 | MySQL/3.23.53]

 Ivo Fokkema
 PHP  MySQL programmer
 Leiden University Medical Centre
 Netherlands


   
   
  
  
 
 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Ereg meadache

2002-11-18 Thread Mako Shark
this is probably not at all what you want, but i
wrote it just in case.
.
.
.
if 1 is in the string it will return either
middle, left, right or only.. if it is not it
will return false.

The problem with this is that I need to do it at the
Linux level, or else I'm not saving PHP the trouble of
searching through every file to find it.



__
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Ereg headache

2002-11-15 Thread Gustaf Sjoberg
hi,
this is probably not at all what you want, but i wrote it just in case.

?
function pos1($numbers) {
if ($numbers) {
if ($numbers == '1')
return only;
if (ereg(^1.+, $numbers))
return left;
if (ereg(.+1$, $numbers))
return right;
if (ereg(.+(1).+, $numbers))
return middle;
}
return false;
}
$text = 3, 2, 1, 4;
if pos1($text)
echo pos1($text);
?

if 1 is in the string it will return either middle, left, right or only.. if 
it is not it will return false.

On Fri, 15 Nov 2002 08:49:23 -0800 (PST)
[EMAIL PROTECTED] (Mako Shark) wrote:

I have a real problem that I can't seem to figure out.
I need an ereg pattern to search for a certain string
(below). All this is being shelled to a Unix grep
command because I'm looking this up in very many
files.

I've made myself a INPUT TYPE=HIDDEN tag that
contains in the value attribute a list of
comma-delimited numbers. I need to find if a certain
number is in these tags (and each file contains one
tag). I need an ereg statement that will let me search
these lines to see if a number exists, obviously in
the beginning or the end or the middle or if it's the
only number in the list. Here's what I mean (searching
for number 1):

INPUT TYPE = HIDDEN NAME = numbers VALUE =
1,2,3,4,5   //beginning

INPUT TYPE = HIDDEN NAME = numbers VALUE =
0,1,2,3,4,5   //middle

INPUT TYPE = HIDDEN NAME = numbers VALUE =
5,4,3,2,1   //end

INPUT TYPE = HIDDEN NAME = numbers VALUE = 1  
 //only

This is frustrating me, because each solution I come
up with doesn't work. Here is my grep/ereg statement
so far:

$commanumberbeginning = [[0-9]+,]*; //this allows 0
or more numbers before it, and if there are any, they
must have 1 or more digits followed by a comma

$commanumberend = [,[0-9]+]*; // this allows 0 or
more numbers after it, and if there are any, they must
have a comma followed by 1 or more digits

$ereg-statement=$commanumberbeginning .
$numbertosearchfor . $commanumberbeginning;
//$numbertosearchfor will be obtained through a select
control in a form

grep 'INPUT TYPE = HIDDEN NAME = numbers VALUE =
$ereg-statement' *.html

This problem is kicking my butt. Any help?

__
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Ereg headache

2002-11-15 Thread Gustaf Sjoberg
or.. if there can be only one instance of the number you can easily calculate it's 
position with

strlen($numbers)

and strpos($numbers, 1);

if strlen returns 5 and strpos 5 you'll know it was far right.. if strpos returns 1 
and strlen 1 it's to the left.. and if strpos  strlen but not 1 it's in the middle.. 
etc.

On Sat, 16 Nov 2002 00:04:50 +0100
[EMAIL PROTECTED] (Gustaf Sjoberg) wrote:

hi,
this is probably not at all what you want, but i wrote it just in case.

?
function pos1($numbers) {
if ($numbers) {
if ($numbers == '1')
return only;
if (ereg(^1.+, $numbers))
return left;
if (ereg(.+1$, $numbers))
return right;
if (ereg(.+(1).+, $numbers))
return middle;
}
return false;
}
$text = 3, 2, 1, 4;
if pos1($text)
echo pos1($text);
?

if 1 is in the string it will return either middle, left, right or only.. if 
it is not it will return false.

On Fri, 15 Nov 2002 08:49:23 -0800 (PST)
[EMAIL PROTECTED] (Mako Shark) wrote:

I have a real problem that I can't seem to figure out.
I need an ereg pattern to search for a certain string
(below). All this is being shelled to a Unix grep
command because I'm looking this up in very many
files.

I've made myself a INPUT TYPE=HIDDEN tag that
contains in the value attribute a list of
comma-delimited numbers. I need to find if a certain
number is in these tags (and each file contains one
tag). I need an ereg statement that will let me search
these lines to see if a number exists, obviously in
the beginning or the end or the middle or if it's the
only number in the list. Here's what I mean (searching
for number 1):

INPUT TYPE = HIDDEN NAME = numbers VALUE =
1,2,3,4,5   //beginning

INPUT TYPE = HIDDEN NAME = numbers VALUE =
0,1,2,3,4,5   //middle

INPUT TYPE = HIDDEN NAME = numbers VALUE =
5,4,3,2,1   //end

INPUT TYPE = HIDDEN NAME = numbers VALUE = 1  
 //only

This is frustrating me, because each solution I come
up with doesn't work. Here is my grep/ereg statement
so far:

$commanumberbeginning = [[0-9]+,]*; //this allows 0
or more numbers before it, and if there are any, they
must have 1 or more digits followed by a comma

$commanumberend = [,[0-9]+]*; // this allows 0 or
more numbers after it, and if there are any, they must
have a comma followed by 1 or more digits

$ereg-statement=$commanumberbeginning .
$numbertosearchfor . $commanumberbeginning;
//$numbertosearchfor will be obtained through a select
control in a form

grep 'INPUT TYPE = HIDDEN NAME = numbers VALUE =
$ereg-statement' *.html

This problem is kicking my butt. Any help?

__
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Ereg help

2002-10-25 Thread Erwin

 William Glenn [EMAIL PROTECTED] wrote in message
news:003101c27c3b$ff8c61a0$6401a8c0;cortez.co.charter.net...
 Hey all,
 I've been fighting this all night, I need a bit of help. I have a string
like.

 #21-935 Item Description: $35.95

 Where the part # could be 10-2034 a combination of 2 and 3 or 4 digits,
and the price could be a combination of 1,2,3 . 2 digits. I want to chop
that string into Part # / Description / Price.

 I'd appreciate any help, I know this is probably real simple :) Thanks in
advance.

Try:

?
$item = '#21-935 Item Description: $35.95';
$all = explode( ' ', $item );
$part_nr = substr( array_shift( $all ), 1 );
$rest = explode( '$', implode( ' ', $all ) );
$description = substr( trim( $rest[0] ), 0, -1 );
$price = $rest[1];
?

I bet there is a much nicer (and maybe faster way), but this is by far the
easiest (it doesn't cost one night) ;-))
One hundred thousand of these iterations took about 2 seconds...

Grtz Erwin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: ereg size limit???

2002-04-22 Thread liljim

Hi,


Sp [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I am trying to validate my input with ereg but I get the error Warning:
 REG_BADBR when I try over 255 characters.  Is there anyway around this?

 Works
 =
 if(eregi('^[A-Za-z]{1,255}$', test sentence))
   echo valid input;

 Doesn't Work
 
 if(eregi('^[A-Za-z]{1,256}$', test sentence))
   echo valid input;


First off, you're using eregi (case insensitive), but defining a-zA-Z (a
through z, case insensitive) in your characters class. You could just use
ereg and leave the character class as it is, or drop the A-Z from the eregi
version.

Secondly, I'd amend your code to:
^[a-z]+$

And thirdly, I'd just use a combination of ereg / preg_* functions and
strlen.

if(preg_match(/^[a-z]+$/i, $string)  strlen($string)  255)
{
echo Whatever.;
}

I'm not sure why you're getting that error, but then again, I haven't
bothered reading up about it :)

James



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Re: ereg size limit???

2002-04-22 Thread SP

Hey James, yeah you're right that was a typo, ereg was what I meant.  Thanks
your suggestion worked and plus I think preg is much faster then ereg so
that's cool.


-Original Message-
From: liljim [mailto:[EMAIL PROTECTED]]
Sent: April 22, 2002 4:44 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: ereg size limit???


Hi,


Sp [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I am trying to validate my input with ereg but I get the error Warning:
 REG_BADBR when I try over 255 characters.  Is there anyway around this?

 Works
 =
 if(eregi('^[A-Za-z]{1,255}$', test sentence))
   echo valid input;

 Doesn't Work
 
 if(eregi('^[A-Za-z]{1,256}$', test sentence))
   echo valid input;


First off, you're using eregi (case insensitive), but defining a-zA-Z (a
through z, case insensitive) in your characters class. You could just use
ereg and leave the character class as it is, or drop the A-Z from the eregi
version.

Secondly, I'd amend your code to:
^[a-z]+$

And thirdly, I'd just use a combination of ereg / preg_* functions and
strlen.

if(preg_match(/^[a-z]+$/i, $string)  strlen($string)  255)
{
echo Whatever.;
}

I'm not sure why you're getting that error, but then again, I haven't
bothered reading up about it :)

James



--
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] Re: Ereg ()

2002-04-16 Thread Jas

If you look on php.net and run a search on ereg() you will find examples on
how to use regex.  Your string would look like this:
ereg('[a-z][A-Z][0-9]{7}')
With your special characters I am not sure how that would work but check out
php.net.
hth
Jas



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re : Ereg ()

2002-04-16 Thread DrouetL


thanks to all of you for you help.

regards

Laurent



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Ereg/replace/i/ or something ??

2002-01-30 Thread J Smith


Try 

ereg(^[0-9]{10}$, $cust_tel);

Quick explanation (I get the feeling you're new at regexes):

^ - beginning of string
[0-9] - any number between 0 and 9 inclusive
{10} - exactly ten times
$ - end of string

There ya go.

J


B. Verbeek wrote:

 Hello,
 
 I want to check the data from a form-field if it excists only of digits
 (0-9) and nothing else.
 
 How do I use the ereg()-function for this?
 
 ereg([0-9],$cust_tel, $cust_tel);  
 
 It is also to turn it around but then the pattern will get larger because
 it has to contain:
  / '.,-)(*^%# a-z A-Z and so on...
 
 The field has to be 10 digits long and has to contain only digits!!!
 
 
 Can anyone help me?
 
 Regards,
 
 Bart


-- 
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] Re: Ereg/replace/i/ or something ??

2002-01-30 Thread liljim

Hi Bart,

 I want to check the data from a form-field if it excists only of digits
 (0-9) and nothing else.

 How do I use the ereg()-function for this?

Well, I prefer the preg_functions

if (!preg_match(/^[0-9]{10}$/, $string)) {
// contains stuff other than numbers, or is less than 10 digits in length.
}

You could also just use is_int()
http://www.php.net/manual/en/function.is-int.php
and strlen()
http://www.php.net/manual/en/function.strlen.php


 ereg([0-9],$cust_tel, $cust_tel);  

 It is also to turn it around but then the pattern will get larger because
it
 has to contain:
  / '.,-)(*^%# a-z A-Z and so on...

 The field has to be 10 digits long and has to contain only digits!!!

Huh?

If you just want digits, then where've those other patterns come from?  Do
you mean you want anything BUT numbers?

Ok:
if (!preg_match(/^[^0-9]+$/, $string_without_numbers)) {
// string contains numbers
}

otherwise, please clarify.

James



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




Re: [PHP] Re: Ereg/replace/i/ or something ??

2002-01-30 Thread Lars Torben Wilson

On Wed, 2002-01-30 at 08:16, liljim wrote:
 Hi Bart,
 
  I want to check the data from a form-field if it excists only of digits
  (0-9) and nothing else.
 
  How do I use the ereg()-function for this?
 
 Well, I prefer the preg_functions
 
 if (!preg_match(/^[0-9]{10}$/, $string)) {
 // contains stuff other than numbers, or is less than 10 digits in length.
 }
 
 You could also just use is_int()
 http://www.php.net/manual/en/function.is-int.php
 and strlen()
 http://www.php.net/manual/en/function.strlen.php

Just a small correction--you should use is_numeric(), not is_int();
form fields are always presented as strings.


Torben

-- 
 Torben Wilson [EMAIL PROTECTED]
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506


-- 
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] Re: ereg

2001-11-27 Thread lallous

I'm not sure if the ereg supports the inline greedy modifier like:

.+? or .*?

so:
 ereg(\?php.*?\?\, $html, $phpIncludes);

if not use preg_match() instead...

Christoph Starkmann [EMAIL PROTECTED] wrote in message
B120D7EC8868D411A63D0050040EDA771118F3@XCHANGE">news:B120D7EC8868D411A63D0050040EDA771118F3@XCHANGE...
 As far as I can say, a simple ereg-command is always greedy, isn't it?
 Can you tell me how to switch greedy off?

 I want to find everything between the start- and end-php-tags:

 $phpIncludes = array();
 ereg(\?php.*\?\, $html, $phpIncludes);

 where $html contains the entire page, containing one php-script-section
 at the very top and one at the very botton, and maybe some inbetween.

 Now the above ereg always returns me the entire site in $phpIncludes[0];

 All help is appreciated, thanx a lot,

 cheers,

 Kiko

 -
 It's not a bug, it's a feature.
 christoph starkmann
 mailto:[EMAIL PROTECTED]
 http://www.fh-augsburg.de/~kiko
 ICQ: 100601600
 -



-- 
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] Re: ereg expr guru

2001-10-02 Thread Richard Lynch

http://php.net/strtok

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
- Original Message -
From: Dave Vanauken [EMAIL PROTECTED]
Newsgroups: php.general
To: PHP General Mailing List [EMAIL PROTECTED]
Sent: Monday, September 24, 2001 10:05 AM
Subject: ereg expr guru


 text file

 [other stuff]
 #%start dynamic %#
 #%start site [identifier] %#
 [contents]
 #%stop site [identifier] %#
 #%start site [identifier] %#
 [contents]
 #%stop site [identifier] %#
 #%start site [identifier] %#
 [contents]
 #%stop site [identifier] %#...
 #%stop dynamic %#
 [other stuff]

 already have the ability to parse out all the dynamic stuff (stuff between
the
 start and stop dynamic tags).  Once we have the string of all the sites,
am
 having problems getting that to parse out into a usabe array.

 need to parse the content between the dynamic tags and return an array
with
 [identifier] = [contents]
 [identifier] = [contents]...

 ideas?

 Dave



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