Re: [PHP] Re: Regular Expression to get the whole Comma Separated String in Array Key

2010-07-01 Thread Richard Quadling
On 1 July 2010 06:47, Gaurav Kumar kumargauravjuke...@gmail.com wrote:
 Hey Richard,

 Thanks!!! You have resolved my problem..

 GK


 On Wed, Jun 30, 2010 at 7:42 PM, Gaurav Kumar
 kumargauravjuke...@gmail.comwrote:

 Hi All,

 Need help in resolving the below problem-


 I would like to get the whole comma separated string into an array value-

 1. $postText = chapters 5, 6, 7, 8;
 OR
 2. $postText = chapters 5, 6;
 OR
 3. $postText = chapters 5, 6, 7;

 What i have done so far is-
 preg_match('/chapter[s]*[ ]*(\d+, \d+, \d+)/i', $postText, $matches);

 The above will exactly match the third value $postText = chapters 5, 6,
 7;

 By Above $matches will contain a value of : $matches[1] = '5, 6, 7';

 Now i need a SINGLE regular expression which can match first, second
 variable above or any number of comma separated string and IMPORTANTLY
 provide me that whole comma separated sting value (as above) in single array
 key element like below-

 $matches[1] = '5, 6, 7';
 OR
 $matches[1] = '5, 6';
 OR
 $matches[1] = '5, 6, 7, 8, 9';


 Also I have to use regular expression only as the flow of the code does not
 permit to use any other method to get comma separated string from the
 master/base string.

 Thanks,

 Gaurav Kumar






No problem.

If you are on Windows, then the RegexBuddy application from JGSoft is
pretty good. It allows you to build regex in a step by step way with a
full description of what the regex will do, along with testing and
code snippets. Also has a lot of examples to work from and a built in
support forum.

BTW. I'm not connected to JGSoft. Just a happy licensee.

Richard.
-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



[PHP] Re: Regular Expression to get the whole Comma Separated String in Array Key

2010-06-30 Thread Jo�o C�ndido de Souza Neto
Not tested, but I think it should work:

preg_match_all('/(\d+),/', $postText, $matches);

-- 
João Cândido de Souza Neto

Gaurav Kumar kumargauravjuke...@gmail.com escreveu na mensagem 
news:aanlktikdb_ismnkpomicxzsfzixg4dedznunrcimj...@mail.gmail.com...
 Hi All,

 Need help in resolving the below problem-


 I would like to get the whole comma separated string into an array value-

 1. $postText = chapters 5, 6, 7, 8;
 OR
 2. $postText = chapters 5, 6;
 OR
 3. $postText = chapters 5, 6, 7;

 What i have done so far is-
 preg_match('/chapter[s]*[ ]*(\d+, \d+, \d+)/i', $postText, $matches);

 The above will exactly match the third value $postText = chapters 5, 6, 
 7;

 By Above $matches will contain a value of : $matches[1] = '5, 6, 7';

 Now i need a SINGLE regular expression which can match first, second
 variable above or any number of comma separated string and IMPORTANTLY
 provide me that whole comma separated sting value (as above) in single 
 array
 key element like below-

 $matches[1] = '5, 6, 7';
 OR
 $matches[1] = '5, 6';
 OR
 $matches[1] = '5, 6, 7, 8, 9';


 Also I have to use regular expression only as the flow of the code does 
 not
 permit to use any other method to get comma separated string from the
 master/base string.

 Thanks,

 Gaurav Kumar
 



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



[PHP] Re: Regular Expression to get the whole Comma Separated String in Array Key

2010-06-30 Thread Gaurav Kumar
Hey Richard,

Thanks!!! You have resolved my problem..

GK


On Wed, Jun 30, 2010 at 7:42 PM, Gaurav Kumar
kumargauravjuke...@gmail.comwrote:

 Hi All,

 Need help in resolving the below problem-


 I would like to get the whole comma separated string into an array value-

 1. $postText = chapters 5, 6, 7, 8;
 OR
 2. $postText = chapters 5, 6;
 OR
 3. $postText = chapters 5, 6, 7;

 What i have done so far is-
 preg_match('/chapter[s]*[ ]*(\d+, \d+, \d+)/i', $postText, $matches);

 The above will exactly match the third value $postText = chapters 5, 6,
 7;

 By Above $matches will contain a value of : $matches[1] = '5, 6, 7';

 Now i need a SINGLE regular expression which can match first, second
 variable above or any number of comma separated string and IMPORTANTLY
 provide me that whole comma separated sting value (as above) in single array
 key element like below-

 $matches[1] = '5, 6, 7';
 OR
 $matches[1] = '5, 6';
 OR
 $matches[1] = '5, 6, 7, 8, 9';


 Also I have to use regular expression only as the flow of the code does not
 permit to use any other method to get comma separated string from the
 master/base string.

 Thanks,

 Gaurav Kumar





Re: [PHP] Re: Regular Expression Backreference in subpattern.

2008-09-28 Thread Nathan Rixham

Shiplu wrote:

Sorry The previous code was wrong,
Its the correct version,

$x = a b;c d;e f;;
preg_match('/(?Pkeys\w) (?Pvalues\w)/',$x,$m);
print_r($m);

Now I am using backrefrence \1 in in ?P option like (?P\1\d+).

and I got the error.



thought I best update for courtesy sake; I spent a good chunk of time on 
this yesterday, read all the regex stuff I could find, and the closest I 
could get was to use recursive sub patterns, however there was no way to 
make a named subpattern name (keys) be a backreference / variable.. ie 
$1 \1 \\1 will never work.


even using this method you're still going to have to combine the two 
arrays to get what you want ($m['keys'] with $m['values'])


Regards  do let me know if you manage!

Nathan

ps: there may be something in the ?name syntax; I don't think so though..

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



[PHP] Re: Regular Expression Backreference in subpattern.

2008-09-27 Thread Nathan Rixham

Shiplu wrote:

The string is tdcharge/tdtd100/td.
I want and array( charge=100).
I am using this regular expression,
'/td([^]+)\/tdtd(?P\1\d+)\/td/'.


But its not working..

I get this error.,
PHP Warning:  preg_match(): Compilation failed: syntax error after (?P
at offset 25 in E:\src\php\WebEngine\- on line 4

any idea?




$string = 'tdcharge/tdtd100/td';
preg_match('|td(.*)/tdtd(\d+)/td|', $string , $out);
print_r( $out );

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



[PHP] Re: Regular Expression Backreference in subpattern.

2008-09-27 Thread Al

What's the complete row? e.g.,

trtdcharge/tdtd100/td/tr

Or, are there other td cells in the row?

Shiplu wrote:

The string is tdcharge/tdtd100/td.
I want and array( charge=100).
I am using this regular expression,
'/td([^]+)\/tdtd(?P\1\d+)\/td/'.


But its not working..

I get this error.,
PHP Warning:  preg_match(): Compilation failed: syntax error after (?P
at offset 25 in E:\src\php\WebEngine\- on line 4

any idea?



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



Re: [PHP] Re: Regular Expression Backreference in subpattern.

2008-09-27 Thread Shiplu
On 9/27/08, Nathan Rixham [EMAIL PROTECTED] wrote:
 Shiplu wrote:

  The string is tdcharge/tdtd100/td.
  I want and array( charge=100).
  I am using this regular expression,
  '/td([^]+)\/tdtd(?P\1\d+)\/td/'.
 
 
  But its not working..
 
  I get this error.,
  PHP Warning:  preg_match(): Compilation failed: syntax error after (?P
  at offset 25 in E:\src\php\WebEngine\- on line 4
 
  any idea?
 
 


  $string = 'tdcharge/tdtd100/td';
  preg_match('|td(.*)/tdtd(\d+)/td|', $string ,
 $out);
  print_r( $out );

You didnt get my point,.
your codes output will be
Array (2) {
[0] = charge,
[1]= 100
}

But I want this,
Array (1) {
charge = 100
}

Thats why I used ?Pname syntax, In name I used \1, means the last
matched patter would be the key.

I can do this by preg_match_all(), then array_combine() funciton.
But I was thinking if I could make it with calling only preg_match_all
-- 
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu

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



Re: [PHP] Re: Regular Expression Backreference in subpattern.

2008-09-27 Thread Shiplu
On 9/27/08, Al [EMAIL PROTECTED] wrote:
 What's the complete row? e.g.,

  trtdcharge/tdtd100/td/tr

  Or, are there other td cells in the row?
No TD cells. forget the real world problem.
I made the exact replica of that. I need the sample work.


-- 
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu

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



[PHP] Re: Regular Expression Backreference in subpattern.

2008-09-27 Thread Al



Shiplu wrote:

The string is tdcharge/tdtd100/td.
I want and array( charge=100).
I am using this regular expression,
'/td([^]+)\/tdtd(?P\1\d+)\/td/'.


But its not working..

I get this error.,
PHP Warning:  preg_match(): Compilation failed: syntax error after (?P
at offset 25 in E:\src\php\WebEngine\- on line 4

any idea?


$pattern=%td(\w*)/tdtd(\d+)/td%;
$str=tdcharge/tdtd100/td;
preg_match($pattern, $str, $matches);

Make a new array with  $new= array($matches[1] = $matches[2]);

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



[PHP] Re: Regular Expression Backreference in subpattern.

2008-09-27 Thread Nathan Rixham

Shiplu wrote:

The string is tdcharge/tdtd100/td.
I want and array( charge=100).
I am using this regular expression,
'/td([^]+)\/tdtd(?P\1\d+)\/td/'.


But its not working..

I get this error.,
PHP Warning:  preg_match(): Compilation failed: syntax error after (?P
at offset 25 in E:\src\php\WebEngine\- on line 4

any idea?



it seem's everybody is giving you the same answers; here's a definitive 
look at the problem (as far as I'm aware)


all preg_* functions can only return back string's, or array's of 
strings; there is no method of returning back an associative array as 
you would like; the closest you can get is by using preg_replace or 
preg_replace_callback as follows:


print_r( preg_replace_callback('|td(.*)/tdtd(\d+)/td|', 
create_function(

'$matches',
'return array($matches[0],$matches[1]);'
), $string) );

this will fall as the internals of preg* casts the array to a string

alternative:

print_r( preg_replace('|td(.*)/tdtd(\d+)/td|e', 
'array($1,$2)', $string) );


this will also fail as the internals of preg* casts the array to a string.

similarly all other options you could go down such as simple explodes, 
strip_tags or even more complex stream filters will only allow you to 
return strings, or numerical array's of strings.


This leaves you high and dry I'm afraid - the only thing for it is to 
create a simple function to handle this for you; something like


function td_thing( $string ) {
$a = preg_replace('|td(.*)/tdtd(\d+)/td|e', '$1 $2', $string);
$b = explode(' ', $a);
return array($b[0] = $b[1]);
}

maybe just maybe you or I or somebody else can find a way to do this 
easily in one line; but for now a function similar to above is the best 
you can do..


Regards

Nathan

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



Re: [PHP] Re: Regular Expression Backreference in subpattern.

2008-09-27 Thread Shiplu
On 9/27/08, Nathan Rixham [EMAIL PROTECTED] wrote:
 Shiplu wrote:

  The string is tdcharge/tdtd100/td.
  I want and array( charge=100).
  I am using this regular expression,
  '/td([^]+)\/tdtd(?P\1\d+)\/td/'.
 
 
  But its not working..
 
  I get this error.,
  PHP Warning:  preg_match(): Compilation failed: syntax error after (?P
  at offset 25 in E:\src\php\WebEngine\- on line 4
 
  any idea?
 
 

  it seem's everybody is giving you the same answers; here's a definitive
 look at the problem (as far as I'm aware)

  all preg_* functions can only return back string's, or array's of strings;
 there is no method of returning back an associative array as you would like;

you can return an array which has friendly name. run the following code,

$x = a b;c d;e f;;
preg_match('/(?Pkeys\w) (?Pvalues\w)/',$x,$m);
print_r($m);


allso run this code too for backreference idea,

$y = 'a a;b c;d d;e f;f g;h i';
preg_match_all('/(\w) (\1)/',$y,$m);
print_r($m);
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu

Stop Top Posting.

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



Re: [PHP] Re: Regular Expression Backreference in subpattern.

2008-09-27 Thread Shiplu
Sorry The previous code was wrong,
Its the correct version,

$x = a b;c d;e f;;
preg_match('/(?Pkeys\w) (?Pvalues\w)/',$x,$m);
print_r($m);

Now I am using backrefrence \1 in in ?P option like (?P\1\d+).

and I got the error.

-- 

Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu

Stop Top Posting.

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



[PHP] Re: Regular Expression just one step away from what I need....

2007-08-17 Thread M. Sokolewicz

Jay Blanchard wrote:

Given the string 'foo''bar''glorp' (all quotes are single quotes)I had
hoped to find a regular expression using preg_match that would return an
array containing just those words without having to go through
additional gyrations, like exploding a string to get an array. I have
only had limited luck

$theString = 'foo''bar''glorp';
preg_match( /\'(.*)\'/, $theString, $matches);
print_r($matches);

Array
(
[0] = 'foo''bar''glorp'
[1] = foo''bar''glorp
)

Of course $matches[0] has the entire string and $matches[1] contains the
returned string minus the leading and trailing single quote. I can
explode $matches[1] to get what I want, but it is an extra step and I am
sure that I have done this before but cannot locate the code in
question. I would like the results to be

Array
(
[0] = 'foo''bar''glorp'
[1] = foo
[2] = bar
[3] = glorp
)

That way I can use the $matches array without having to create another
array to hold the values. I feel as if I am really close on the regex to
do this, but cannot seem to find (after much head scratching and teeth
gnashing) the proper solution.

Much thanks!


2(-3) steps:
1. Make it _un_greedy (preg_* are greedy by default, so /'(.*)'/U will 
match foo''bar''glorp, making it ungreedy (/U modifier) would make it 
match just foo

2. Make it fetch _all_ matches, use preg_match_all
(3. there's no need to escape single quotes in this string :))

The following works:
preg_match_all(/'(.*)'/U, 'foo''bar''glorp', $matches);
print_r($matches);

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



[PHP] Re: regular expression help!

2007-01-18 Thread Al

First stripslashes() and all newlines [\n\r*]. It makes the regex much easier.

$pattern= %img\x20[\w\d\=\x20]+(src=\x20*\)([/\w\d\.]+)[\\x20]*/%i;

preg_match($pattern, $string, $match); If more than one in the string, use 
preg_match_all().


Now print_r($match); so you can see the result.

Now, read the doc and see why each term is used. Note, I assumed your string can 
have some variation and still be W3C compatible e.g., src=. and

src= , etc. You may need to be able to handle additional variations.

Al

William Stokes wrote:

Hello,

Can someone here give me a glue how to do the following. I guess I need to 
use regular expressions here. I have absolutely zero experience with regular 
expressions. (if there's another way to do this I don't mind. I jus need to 
get this done somehow :)


I need to strip all characters from the following text string exept the 
image path...


img width=\99\ height=\120\ border=\0\ 
src=\../../images/new/thumps/4123141112007590373240.jpg\ /...and then 
store the path to DB. Image path lengh can vary so I guess that I need to 
extract all characters after scr=\until next\or somethig 
similar.


Thanks for your advise!
-Will


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



[PHP] Re: Regular expression to find from start of string to first space

2006-08-08 Thread Barry

Dave M G schrieb:

PHP,

Shouldn't this regular expression select everything from the start of 
the string to the first space character:


$firstWord = preg_match('#^*(.*) #iU', $word);

It doesn't, so clearly I'm wrong, but here's why I thought it would:

The enclosing has marks, #, I *think* just encloses the expression. I 
was told to use them before, but I can't find them here:

http://jp2.php.net/manual/en/reference.pcre.pattern.syntax.php

The caret, ^, says to start at the beginning of the line.

The first asterix, * after the caret says to use any starting character.

The space just before the second # is the closing character of my search.

The (.*) in the middle says to take anything in between the beginning 
of the line and the space.


iU says, be case insensitive, and don't be greedy.

So, it should start at the beginning of the line and get everything up 
to the first space. But it doesn't work.


Where did I go wrong?

--
Dave M G

http://www.rexv.org/

This is a quite good site to learn and test regexpressions.

Barry

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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



[PHP] Re: Regular expression to find from start of string to first space

2006-08-08 Thread Adam Zey

Dave M G wrote:

PHP,

Shouldn't this regular expression select everything from the start of 
the string to the first space character:


$firstWord = preg_match('#^*(.*) #iU', $word);

It doesn't, so clearly I'm wrong, but here's why I thought it would:

The enclosing has marks, #, I *think* just encloses the expression. I 
was told to use them before, but I can't find them here:

http://jp2.php.net/manual/en/reference.pcre.pattern.syntax.php

The caret, ^, says to start at the beginning of the line.

The first asterix, * after the caret says to use any starting character.

The space just before the second # is the closing character of my search.

The (.*) in the middle says to take anything in between the beginning 
of the line and the space.


iU says, be case insensitive, and don't be greedy.

So, it should start at the beginning of the line and get everything up 
to the first space. But it doesn't work.


Where did I go wrong?

--
Dave M G


You should always avoid using regular expressions where simple string 
functions will do; regular expressions are a lot slower.


Your problem could easily be solved with something like this:

$firstWord = substr($word, 0, strpos($word,  ));

I think I've got that right, I'm always forgetting if I need to add or 
subtract something from the length parameter :P


Regards, Adam.

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



[PHP] Re: regular expression to extract from the middle of a string

2006-07-14 Thread Al

Steve Turnbull wrote:

Hey folks

I don't want to just get you to do the work, but I have so far tried
in vain to achieve something...

I have a string similar to the following;

cn=emailadmin,ou=services,dc=domain,dc=net

I want to extract whatever falls between the 'cn=' and the following
comma - in this case 'emailadmin'.

Question(s);
is this possible via a regular expression?
does php have a better way of doing this?

Some pointers would be greatly appreciated. Once I have working, I will
be creating a function which will cater for this and will post to this
list if anyone is interested?

Cheers
Steve



$pattern= %cn=([a-z]+)%i;   //Or, if numbers are ok, you an use \w 
instead of [a-z]

preg_match($pattern, $your_string, $match);

$value= $match[1];

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



[PHP] Re: regular expression to extract from the middle of a string

2006-07-14 Thread Adam Zey

Steve Turnbull wrote:

Hey folks

I don't want to just get you to do the work, but I have so far tried
in vain to achieve something...

I have a string similar to the following;

cn=emailadmin,ou=services,dc=domain,dc=net

I want to extract whatever falls between the 'cn=' and the following
comma - in this case 'emailadmin'.

Question(s);
is this possible via a regular expression?
does php have a better way of doing this?

Some pointers would be greatly appreciated. Once I have working, I will
be creating a function which will cater for this and will post to this
list if anyone is interested?

Cheers
Steve



The fastest way to do this probably does not involve explodes or regular 
expressions. I would wager that the fastest method would be to do a 
strpos to find cn=, then a strpos to find the next comma (strpos 
supports offsets to start looking for), and then substr out the segment 
you've identified.


However, if cn= is ALWAYS first, it's actually a lot simpler. Then it 
becomes something like this:


$mystring = cn=emailadmin,ou=services,dc=domain,dc=net;
$cnpart = substr($mystring, 2, strpos($mystring, ,) - 3 );

My offsets might be a bit off there, I always get confused with them and 
have to verify by running the code in case I mixed up a zero-based 
character position or something :P


Regards, Adam.

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



[PHP] Re: Regular expression

2006-01-30 Thread Al

Barry wrote:

Simple reg help please

i want to match the last , in a,b,c,d and replace it with  and 

i tried ereg_replace(,([a-zA-z])*$, and ,$string);

but i forgot how to add the d which is also matched now back to the
 and 

Can you give any good reg_exp sites where to learn it?
Its long ago since i used reg exp and i lost the hang of it... :(

btw. any sites that have reg_exp that works witht PHP would be fine.
i know http://www.regular-expressions.info/tutorial.html
But that examples dont work with preg_match and ereg.

Thanks ^_^


Try this:

$pattern= %,([\w\.]+)$%;//put any line ending punctuation in the 
[] 
$replace=  and $1;  //may need $replace=  and  . $1;

$string= preg_replace($pattern, $replace, $string);

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



[PHP] Re: regular expression for time

2005-08-29 Thread Al

babu wrote:

HI,
 
how can i write regular expression for time in 24-hour format i:e, HH:MM:SS. using preg_match.
 
thanks

babu


-
How much free photo storage do you get? Store your holiday snaps for FREE with 
Yahoo! Photos. Get Yahoo! Photos


You need to be more specific about:

What is before and after the time string.  It's probably white-space. That so?

Can your HH, values be without the leading zero, e.g., 2:12:15.

Can you be certain that MM and SS will be included.  If the time is entered by users, they can get lazy and give you 
2, for example.


Given the simplest case.  $pattern= %\s(\d\d:\d\:\d\d)\s%;   [% is simply the delimitor, it can be almost any 
thing.] The \s is optional, it says white-space.


$num= preg($pattern, $string [,$match_array])  $time_value= $match_array[1];  $num of matches in case you want to test 
for none or more than 1.


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



[PHP] Re: Regular expression question

2005-08-11 Thread TalkativeDoggy

How about using the lower() function?

Leon Vismer wrote:
Hi 

I would like to convert from one naming convention within a sql statement to 
another.


I have the following,

code
$str = insert into userComment (userID, userName, userSurname) values (0, 
'Leon', 'Vismer');


$match = array(
/([a-z]+)(ID)/,
/([a-z]+)([A-Z])/
);

$replace = array(
\$1_id,
\$1_\$2
);

$nstr = preg_replace($match, $replace, $str);
echo $nstr .\n;
/code

the above gets me to 
insert into user_Comment (user_id, user_Name, user_Surname) values (0, 'Leon', 
'Vismer')


however I want to get to

insert into user_comment (user_id, user_name, user_surname) values (0, 'Leon', 
'Vismer')


Some help from the regex experts ;-)

Many thanks
--
Leon


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



[PHP] Re: regular expression help

2005-01-21 Thread Jason
Jason wrote:
Simple functions to check  fix if necessary invalid formating of a MAC 
address... I seem to be having problems with the global variable $mac 
not being returned from the fix_mac() function.  Any help is appreciated.

?php
/*
 * ex. 00:AA:11:BB:22:CC
 */
function chk_mac( $mac ) {
global $mac;
 if( eregi( 
^[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}$, 
$mac ) ) {
  return 0;
 } else {
  return 1;
 }
}

/*
 * check validity of MAC  do replacements if necessary
 */
function fix_mac( $mac ) {
 global $mac;
 /* strip the dash  replace with a colon */
 if( eregi( 
^[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}$, 
$mac ) ) {
  $mac = preg_replace( /\-/, :, $mac );
  return $mac;
 }
 /* add a colon for every two characters */
 if( eregi( ^[0-9A-Fa-f]{12}$, $mac ) ) {
  /* split up the MAC and assign new var names */
  @list( $mac1, $mac2, $mac3, $mac4, $mac5, $mac6 ) = @str_split( $mac, 
2 );
  /* put it back together with the required colons */
  $mac = $mac1 . : . $mac2 . : . $mac3 . : . $mac4 . : . $mac5 . 
: . $mac6;
  return $mac;
 }
}

// do our checks to make sure we are using these damn things right
$mac1 = 00aa11bb22cc;
$mac2 = 00-aa-11-bb-22-cc;
$mac3 = 00:aa:11:bb:22:cc;
// make sure it is global
global $mac;
// if mac submitted is invalid check  fix if necessary
if( chk_mac( $mac1 ) != 0 ) {
 $mac = fix_mac( $mac1 ); echo $mac1 .  converted to  . $mac . br;
}
if( chk_mac( $mac2 ) != 0 ) {
 $mac = fix_mac( $mac2 ); echo $mac2 .  converted to  . $mac . br;
}
if( chk_mac( $mac3 ) != 0 ) {
 $mac = fix_mac( $mac3 ); echo $mac3 .  converted to  . $mac . br;
}
?
Still does not resolve the problem.  declaring $mac as global in the 
chk_mac() function.

--
Jason Gerfen
Student Computing
Marriott Library
801.585.9810
[EMAIL PROTECTED]
And remember... If the ladies
 don't find you handsome, they
 should at least find you handy...
 ~The Red Green show
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: regular expression help

2005-01-21 Thread RaTT
Hi, 

From what i can see you dont even need to call global, as your passing
variables to the function ? this could be causing the script to
confuse itself.

hth


On Fri, 21 Jan 2005 09:30:21 -0700, Jason [EMAIL PROTECTED] wrote:
 Jason wrote:
  Simple functions to check  fix if necessary invalid formating of a MAC
  address... I seem to be having problems with the global variable $mac
  not being returned from the fix_mac() function.  Any help is appreciated.
 
  ?php
  /*
   * ex. 00:AA:11:BB:22:CC
   */
  function chk_mac( $mac ) {
  global $mac;
   if( eregi(
  ^[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}$,
  $mac ) ) {
return 0;
   } else {
return 1;
   }
  }
 
  /*
   * check validity of MAC  do replacements if necessary
   */
  function fix_mac( $mac ) {
   global $mac;
   /* strip the dash  replace with a colon */
   if( eregi(
  ^[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}$,
  $mac ) ) {
$mac = preg_replace( /\-/, :, $mac );
return $mac;
   }
   /* add a colon for every two characters */
   if( eregi( ^[0-9A-Fa-f]{12}$, $mac ) ) {
/* split up the MAC and assign new var names */
@list( $mac1, $mac2, $mac3, $mac4, $mac5, $mac6 ) = @str_split( $mac,
  2 );
/* put it back together with the required colons */
$mac = $mac1 . : . $mac2 . : . $mac3 . : . $mac4 . : . $mac5 .
  : . $mac6;
return $mac;
   }
  }
 
  // do our checks to make sure we are using these damn things right
  $mac1 = 00aa11bb22cc;
  $mac2 = 00-aa-11-bb-22-cc;
  $mac3 = 00:aa:11:bb:22:cc;
 
  // make sure it is global
  global $mac;
 
  // if mac submitted is invalid check  fix if necessary
  if( chk_mac( $mac1 ) != 0 ) {
   $mac = fix_mac( $mac1 ); echo $mac1 .  converted to  . $mac . br;
  }
  if( chk_mac( $mac2 ) != 0 ) {
   $mac = fix_mac( $mac2 ); echo $mac2 .  converted to  . $mac . br;
  }
  if( chk_mac( $mac3 ) != 0 ) {
   $mac = fix_mac( $mac3 ); echo $mac3 .  converted to  . $mac . br;
  }
 
  ?
 Still does not resolve the problem.  declaring $mac as global in the
 chk_mac() function.
 
 --
 Jason Gerfen
 Student Computing
 Marriott Library
 801.585.9810
 [EMAIL PROTECTED]
 
 And remember... If the ladies
   don't find you handsome, they
   should at least find you handy...
   ~The Red Green show
 
 --
 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: regular expression help

2005-01-21 Thread Jason
You were right, I removed the reference to global $mac and it started 
working great.  Thanks.  It seems sometimes another set of eyes to catch 
stuff really helps... thanks.

Jason wrote:
Jason wrote:
Simple functions to check  fix if necessary invalid formating of a 
MAC address... I seem to be having problems with the global variable 
$mac not being returned from the fix_mac() function.  Any help is 
appreciated.

?php
/*
 * ex. 00:AA:11:BB:22:CC
 */
function chk_mac( $mac ) {
global $mac;
 if( eregi( 
^[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}$, 
$mac ) ) {
  return 0;
 } else {
  return 1;
 }
}

/*
 * check validity of MAC  do replacements if necessary
 */
function fix_mac( $mac ) {
 global $mac;
 /* strip the dash  replace with a colon */
 if( eregi( 
^[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}$, 
$mac ) ) {
  $mac = preg_replace( /\-/, :, $mac );
  return $mac;
 }
 /* add a colon for every two characters */
 if( eregi( ^[0-9A-Fa-f]{12}$, $mac ) ) {
  /* split up the MAC and assign new var names */
  @list( $mac1, $mac2, $mac3, $mac4, $mac5, $mac6 ) = @str_split( 
$mac, 2 );
  /* put it back together with the required colons */
  $mac = $mac1 . : . $mac2 . : . $mac3 . : . $mac4 . : . $mac5 
. : . $mac6;
  return $mac;
 }
}

// do our checks to make sure we are using these damn things right
$mac1 = 00aa11bb22cc;
$mac2 = 00-aa-11-bb-22-cc;
$mac3 = 00:aa:11:bb:22:cc;
// make sure it is global
global $mac;
// if mac submitted is invalid check  fix if necessary
if( chk_mac( $mac1 ) != 0 ) {
 $mac = fix_mac( $mac1 ); echo $mac1 .  converted to  . $mac . br;
}
if( chk_mac( $mac2 ) != 0 ) {
 $mac = fix_mac( $mac2 ); echo $mac2 .  converted to  . $mac . br;
}
if( chk_mac( $mac3 ) != 0 ) {
 $mac = fix_mac( $mac3 ); echo $mac3 .  converted to  . $mac . br;
}
?
Still does not resolve the problem.  declaring $mac as global in the 
chk_mac() function.


--
Jason Gerfen
And remember... If the ladies
 don't find you handsome, they
 should at least find you handy...
 ~The Red Green show
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Regular Expression

2004-11-25 Thread Ing. Ivo F.A.C. Fokkema
On Wed, 24 Nov 2004 13:17:48 -0500, Ankur Os wrote:

 Hi,
 
 This is quite simpal problem that i want to made regular expression which
 can read this kind of structure...
 
 a,b,c
 
 not like this
 
 1.  ,a,a,a
 2.  a,,,aa,,
 3.  a,a,a,,,
 
 means simpal structure with comma (a,b,c...)
Hi,

Try this (untested) :

preg_match('/^([a-c],)*[a-c]$/', $input);

this will match characters a-c separated by commas. Replace 'a-c' by any
range of characters you like.

HTH,

Ivo

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



[PHP] Re: Regular expression

2004-06-30 Thread Aidan Lister
I suggest not using a regex.

There are better tools for parsing an email, for example formail.

$email = `formail -x Return-Path`;

See google.com for more information

Regards,
Aidan


Syed Ghouse [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hi All

will anyone give me a solution to get the name and email address of sender
from the mail text below using regular expression.

The result shud get
name as syed ghouse
and
email as [EMAIL PROTECTED]

--- Mail text start ---

Return-Path: [EMAIL PROTECTED]
Delivered-To: [EMAIL PROTECTED]
Received: (qmail 25523 invoked by uid 508); 19 Jun 2004 06:23:25 -
Received: from localhost (HELO 192.168.90.8) (127.0.0.1)
  by mail.jinis.com with SMTP; 19 Jun 2004 06:23:25 -
Received: from 192.168.90.20 (proxying for 192.168.90.85)
(SquirrelMail authenticated user [EMAIL PROTECTED])
by 192.168.90.8 with HTTP;
Sat, 19 Jun 2004 11:53:25 +0530 (IST)
Message-ID: [EMAIL PROTECTED]
Date: Sat, 19 Jun 2004 11:53:25 +0530 (IST)
Subject: test

From : 'syed ghouse' [EMAIL PROTECTED]

To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED],[EMAIL PROTECTED]
User-Agent: SquirrelMail/1.4.2
MIME-Version: 1.0
Content-Type: text/plain;charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Priority: 3
Importance: Normal

test mail ignore

--- Mail text end ---


Regards

Syed



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



[PHP] Re: Regular expression

2004-06-30 Thread Red Wingate
If you still like to gather the information without using any tools:

$email = explode( \n , $mailText );

foreach ( $email AS $emailLine ) {
  $emailLine = trim( $emailLine );
   
  if ( strtoupper ( substr( $emailLine , 0 , 4 ) ) == 'FROM' ) {
preg_match( '#^from\s*:\s*([^]+)(([^]+))?#si' ,$emailLine ,$parts );
break ;
  }
}

$name  = $parts[1] ;
$email = $parts[3] ;

But you should consider the following:

FROM: Red Wingate [EMAIL PROTECTED]
FROM: Red Wingate
FROM: [EMAIL PROTECTED]
   .

Which makes working like this a pita.

   -- red

 I suggest not using a regex.
 
 There are better tools for parsing an email, for example formail.
 
 $email = `formail -x Return-Path`;
 
 See google.com for more information
 
 Regards,
 Aidan
 
 
 Syed Ghouse [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Hi All
 
 will anyone give me a solution to get the name and email address of sender
 from the mail text below using regular expression.
 
 The result shud get
 name as syed ghouse
 and
 email as [EMAIL PROTECTED]
 
 --- Mail text start ---
 
 Return-Path: [EMAIL PROTECTED]
 Delivered-To: [EMAIL PROTECTED]
 Received: (qmail 25523 invoked by uid 508); 19 Jun 2004 06:23:25 -
 Received: from localhost (HELO 192.168.90.8) (127.0.0.1)
   by mail.jinis.com with SMTP; 19 Jun 2004 06:23:25 -
 Received: from 192.168.90.20 (proxying for 192.168.90.85)
 (SquirrelMail authenticated user [EMAIL PROTECTED])
 by 192.168.90.8 with HTTP;
 Sat, 19 Jun 2004 11:53:25 +0530 (IST)
 Message-ID: [EMAIL PROTECTED]
 Date: Sat, 19 Jun 2004 11:53:25 +0530 (IST)
 Subject: test
 
 From : 'syed ghouse' [EMAIL PROTECTED]
 
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED],[EMAIL PROTECTED]
 User-Agent: SquirrelMail/1.4.2
 MIME-Version: 1.0
 Content-Type: text/plain;charset=iso-8859-1
 Content-Transfer-Encoding: 8bit
 X-Priority: 3
 Importance: Normal
 
 test mail ignore
 
 --- Mail text end ---
 
 
 Regards
 
 Syed

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



Fw: [PHP] Re: Regular expression

2004-06-30 Thread Syed Ghouse

- Original Message -
From: Syed Ghouse [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, June 30, 2004 PM 04:43
Subject: Re: [PHP] Re: Regular expression


 Thanks Aiden for ur help

 i used ur code and i got

 name as Red Wingate[EMAIL PROTECTED]
 and no email.

 So pls correct the code and send me such that i get name and email
 separately.

 Regards
 syed

 - Original Message -
 From: Red Wingate [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, June 30, 2004 PM 04:27
 Subject: [PHP] Re: Regular expression


  If you still like to gather the information without using any tools:
 
  $email = explode( \n , $mailText );
 
  foreach ( $email AS $emailLine ) {
$emailLine = trim( $emailLine );
 
if ( strtoupper ( substr( $emailLine , 0 , 4 ) ) == 'FROM' ) {
  preg_match( '#^from\s*:\s*([^]+)(([^]+))?#si' ,$emailLine
 ,$parts );
  break ;
}
  }
 
  $name  = $parts[1] ;
  $email = $parts[3] ;
 
  But you should consider the following:
 
  FROM: Red Wingate [EMAIL PROTECTED]
  FROM: Red Wingate
  FROM: [EMAIL PROTECTED]
 .
 
  Which makes working like this a pita.
 
 -- red
 
   I suggest not using a regex.
  
   There are better tools for parsing an email, for example formail.
  
   $email = `formail -x Return-Path`;
  
   See google.com for more information
  
   Regards,
   Aidan
  
  
   Syed Ghouse [EMAIL PROTECTED] wrote in message
   news:[EMAIL PROTECTED]
   Hi All
  
   will anyone give me a solution to get the name and email address of
 sender
   from the mail text below using regular expression.
  
   The result shud get
   name as syed ghouse
   and
   email as [EMAIL PROTECTED]
  
   --- Mail text start ---
  
   Return-Path: [EMAIL PROTECTED]
   Delivered-To: [EMAIL PROTECTED]
   Received: (qmail 25523 invoked by uid 508); 19 Jun 2004 06:23:25 -
   Received: from localhost (HELO 192.168.90.8) (127.0.0.1)
 by mail.jinis.com with SMTP; 19 Jun 2004 06:23:25 -
   Received: from 192.168.90.20 (proxying for 192.168.90.85)
   (SquirrelMail authenticated user [EMAIL PROTECTED])
   by 192.168.90.8 with HTTP;
   Sat, 19 Jun 2004 11:53:25 +0530 (IST)
   Message-ID: [EMAIL PROTECTED]
   Date: Sat, 19 Jun 2004 11:53:25 +0530 (IST)
   Subject: test
  
   From : 'syed ghouse' [EMAIL PROTECTED]
  
   To: [EMAIL PROTECTED]
   Cc: [EMAIL PROTECTED],[EMAIL PROTECTED]
   User-Agent: SquirrelMail/1.4.2
   MIME-Version: 1.0
   Content-Type: text/plain;charset=iso-8859-1
   Content-Transfer-Encoding: 8bit
   X-Priority: 3
   Importance: Normal
  
   test mail ignore
  
   --- Mail text end ---
  
  
   Regards
  
   Syed
 
  --
  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: Fw: [PHP] Re: Regular expression

2004-06-30 Thread Red Wingate
First of all check who u credit :p
Secondly why don't you just try to fix it yourself?

There was just a typo in the regexp:
- #^from\s*:\s*([^]+)(([^]+))?#si
+ #^from\s*:\s*([^]+)(([^]+))?#si

Hopefully this will help you even more:

?php

/**
 * @param   string  $runlevel
 * @return  mixed
 */
function fetchSender ( $mailText ) {
  $mailText = explode( \n , $mailText ) ;

  foreach ( $mailText AS $mailLine ) {
$mailLine = trim ( $mailLine ) ;

if ( strtoupper ( substr ( $mailLine , 0 , 4 ) ) == 'FROM' ) {
  preg_match ( '#^\s*FROM\s*:\s*(([^]+)(\([^]+)\)?)#si' ,
$mailLine , $parts );

  break ;
}
  }

  if ( is_array ( $parts ) === FALSE ) {
return FALSE ;
  } else {
return array ( 'name' = isset ( $parts[2] ) ? $parts[2] : 'unknown' ,
 'from' = isset ( $parts[1] ) ? $parts[1] : 'unknown' ,
 'mail' = isset ( $parts[4] ) ? $parts[4] : 'unknown' ) ;
  }
}

/**
 * @param   array   $strings
 * @return  void
 */
function debug_FetchSender ( $strings ) {
  echo 'pre';

  foreach ( $strings AS $string ) {
$sender = fetchSender ( $string );
$sender = array_map ( 'htmlspecialchars' , $sender ) ;

print_r ( $sender );
  }

  echo '/pre';
}

debug_FetchSender ( array ( 'FROM: Red Wingate [EMAIL PROTECTED]' ,
  'FROM: Red Wingate' ,
  'FROM: [EMAIL PROTECTED]' ) ) ;

?

[...]
 Thanks Aiden for ur help

 i used ur code and i got

 name as Red Wingate[EMAIL PROTECTED]
 and no email.

 So pls correct the code and send me such that i get name and email
 separately.

 Regards
 syed
[...]

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



Fw: [PHP] Re: Regular expression

2004-06-30 Thread Syed Ghouse
Yeah i used ur coding below and i got the solution for my problem.

Thanks Aidan

Syed
- Original Message -
From: Syed Ghouse [EMAIL PROTECTED]
To: php mailinglists [EMAIL PROTECTED]
Sent: Wednesday, June 30, 2004 PM 04:45
Subject: Fw: [PHP] Re: Regular expression



 - Original Message -
 From: Syed Ghouse [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, June 30, 2004 PM 04:43
 Subject: Re: [PHP] Re: Regular expression


  Thanks Aiden for ur help
 
  i used ur code and i got
 
  name as Red Wingate[EMAIL PROTECTED]
  and no email.
 
  So pls correct the code and send me such that i get name and email
  separately.
 
  Regards
  syed
 
  - Original Message -
  From: Red Wingate [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Wednesday, June 30, 2004 PM 04:27
  Subject: [PHP] Re: Regular expression
 
 
   If you still like to gather the information without using any tools:
  
   $email = explode( \n , $mailText );
  
   foreach ( $email AS $emailLine ) {
 $emailLine = trim( $emailLine );
  
 if ( strtoupper ( substr( $emailLine , 0 , 4 ) ) == 'FROM' ) {
   preg_match( '#^from\s*:\s*([^]+)(([^]+))?#si' ,$emailLine
  ,$parts );
   break ;
 }
   }
  
   $name  = $parts[1] ;
   $email = $parts[3] ;
  
   But you should consider the following:
  
   FROM: Red Wingate [EMAIL PROTECTED]
   FROM: Red Wingate
   FROM: [EMAIL PROTECTED]
  .
  
   Which makes working like this a pita.
  
  -- red
  
I suggest not using a regex.
   
There are better tools for parsing an email, for example formail.
   
$email = `formail -x Return-Path`;
   
See google.com for more information
   
Regards,
Aidan
   
   
Syed Ghouse [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hi All
   
will anyone give me a solution to get the name and email address of
  sender
from the mail text below using regular expression.
   
The result shud get
name as syed ghouse
and
email as [EMAIL PROTECTED]
   
--- Mail text start ---
   
Return-Path: [EMAIL PROTECTED]
Delivered-To: [EMAIL PROTECTED]
Received: (qmail 25523 invoked by uid 508); 19 Jun 2004
06:23:25 -
Received: from localhost (HELO 192.168.90.8) (127.0.0.1)
  by mail.jinis.com with SMTP; 19 Jun 2004 06:23:25 -
Received: from 192.168.90.20 (proxying for 192.168.90.85)
(SquirrelMail authenticated user [EMAIL PROTECTED])
by 192.168.90.8 with HTTP;
Sat, 19 Jun 2004 11:53:25 +0530 (IST)
Message-ID: [EMAIL PROTECTED]
Date: Sat, 19 Jun 2004 11:53:25 +0530 (IST)
Subject: test
   
From : 'syed ghouse' [EMAIL PROTECTED]
   
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED],[EMAIL PROTECTED]
User-Agent: SquirrelMail/1.4.2
MIME-Version: 1.0
Content-Type: text/plain;charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Priority: 3
Importance: Normal
   
test mail ignore
   
--- Mail text end ---
   
   
Regards
   
Syed
  
   --
   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 General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Fw: [PHP] Re: Regular expression

2004-06-30 Thread Curt Zirzow
* Thus wrote Red Wingate:
 First of all check who u credit :p
 Secondly why don't you just try to fix it yourself?
 
 There was just a typo in the regexp:
 - #^from\s*:\s*([^]+)(([^]+))?#si
 + #^from\s*:\s*([^]+)(([^]+))?#si
 
 Hopefully this will help you even more:
 

You're too nice..

Btw, I need some money. Send me money ASAP. It must be an amount
greater than $200, and be delivered to me directly, thank you.


 ...
 
 ?
 
 [...]
  Thanks Aiden for ur help
 
  i used ur code and i got
 
  name as Red Wingate[EMAIL PROTECTED]
  and no email.
 
  So pls correct the code and send me such that i get name and email
  separately.
 
  Regards
  syed
 [...]
 

Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

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



Re: Fw: [PHP] Re: Regular expression

2004-06-30 Thread Red Wingate
Oh ... you forgot to include your account-info so i won't be able to
send you the money :-/
[...]
You're too nice..
Btw, I need some money. Send me money ASAP. It must be an amount
greater than $200, and be delivered to me directly, thank you.
[...]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Regular expression question

2004-05-27 Thread Jason Barnett
This should work:
^\\ # Don't match if a backslash precedes
\[  # Open bracket
([^\]]+?)   # Text, including whitespace
\]  # Close bracket
By the way, using a tool called The Regex Coach I solved your problem in 
about 10 seconds.  For those having regex problems you might be 
interested in this link, I have found this tool invaluable:

http://www.weitz.de/regex-coach/#install
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Regular Expression

2004-05-05 Thread Tumurbaatar S.
Because the substrings can contain any char-s including
commas. Also I use reg exp not for splitting only but
for validating whether whole string and the substrings
are correctly formatted. Using reg exp requires much less
coding than traditional programming.


 Why not just strip out the braces and explode on commas?  That'll be
 lighter than regexps any day.  If the input is guaranteed to be
 formatted the way you describe, you could do something like:

   $out = explode(,, substr($in, 1, strlen($in)-2));

 -- 
   Paul Chvostek [EMAIL PROTECTED]
   it.canadahttp://www.it.ca/
   Free PHP web hosting!http://www.it.ca/web/

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



[PHP] Re: Regular Expression

2004-05-04 Thread Tumurbaatar S.
Forgot about curly brackets. The above example is:
/^\{(?:(pattern),)*|(pattern)?\}$/

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



[PHP] Re: Regular Expression

2004-05-04 Thread Paul Chvostek
On Wed, May 05, 2004 at 02:26:25PM +0900, Tumurbaatar S. wrote:
 
 There's an input string like {str1,str2,...,strN}. I want to capture
 all these strings and due to complexity of them I use a preg_match_all()
 instead of simple split. A pattern for the matching strings is ready but
 I cannot imagine how to specify that strings are separated by commas
 and the last one is not followed by comma. For example, I'm afraid that
 this pattern /^{(?:(pattern),)*|(pattern)?}$/ can match and capture
 properly constructed input string, but, in addition, this matches if
 the string end is ,}. Any ideas?

Why not just strip out the braces and explode on commas?  That'll be
lighter than regexps any day.  If the input is guaranteed to be
formatted the way you describe, you could do something like:

  $out = explode(,, substr($in, 1, strlen($in)-2));

-- 
  Paul Chvostek [EMAIL PROTECTED]
  it.canadahttp://www.it.ca/
  Free PHP web hosting!http://www.it.ca/web/

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



[PHP] Re: Regular expression checker

2004-03-17 Thread Luis Mirabal
an excelent tool: The Regex Coach, its free and you can grab it from
http://weitz.de/regex-coach/
and its available for windows and linux!

luis.

[EMAIL PROTECTED] escribió en el mensaje
news:[EMAIL PROTECTED]
 Hello all,

 For a while I tried in vain to find a decent regular expression tester.
The closest I found
 was RegExpEditor, by the same people who produce PHPEdit, but I found it
to be slow
 and didn't like its constant bitching about invalid delimiters or some
such thing.

 Anyway, I ended up writing a little tester for Perl-compatible regular
expressions and
 thought I'd share it with you. Maybe it'll come in handy to people who
often need to use
 regular expressions in their projects. Just copy the code below the dotted
line (which
 has Unix line breaks) and save it to a file.

 Cheers,

 Erik

 

 html
 head
 meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
 titleRegular Expression Tester/title
 ?php( isset($_POST['text'])  isset($_POST['regexp']) )
 {
 $error = false;
 if($_POST['mode'] == 'one')
 {
 if( @preg_match('/'.$_POST['regexp'].'/', $_POST['text'], $matches) ===
 false )
 {
 $error = true;
 }
 }
 else
 {
 if( @preg_match_all('/'.$_POST['regexp'].'/', $_POST['text'], $matches)
 === false )
 {
 $error = true;
 }
 }
 }
 ?
 /head
 body style=font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:12px;
 form action=?php print $_SERVER['PHP_SELF']; ? method=post
 enctype=multipart/form-data
 table width=750
 tr
 td width=135div align=rightRegular expression:/div/td
 td width=591
 input name=regexp type=text size=87
 ?php if( isset($_POST['regexp']) ) {print
'value='.$_POST['regexp'].'';} ?
 /
 /td
 /tr
 tr
 td width=135div align=rightText:/div/td
 td width=591
 textarea name=text rows=6 cols=65
 ?php if( isset($_POST['text']) ) {print $_POST['text'];} ?
 /textarea
 /td
 /tr
 tr
 td width=135div align=rightMode:/div/td
 td width=591
 select name=mode
 option value=one
 ?php( isset($_POST['mode'])  $_POST['mode'] == 'one' )
 {
 print 'selected';
 }
 ?
 First match/option
 option value=all
 ?php( isset($_POST['mode'])  $_POST['mode'] == 'all' )
 {
 print 'selected';
 }
 ?
 All matches/option
 /select
 /td
 /tr
 tr
  td width=135nbsp;/td
  tdinput type=submit value=RUN TEST/
 nbsp;nbsp;nbsp;
 input type=reset value=CLEAR FORM//td
 /tr
 /table
 /form
 p/
 div style=background-color:#00; color:#FF;
 table width=750 border=10 bordercolor=#00
 ?php($error)
 {
 exit('trtdspan style=color: lime; font-weight: bold;'.
 'Invalid regular expression!/span/td/tr');
 }
 ( isset($matches)  !empty($matches[0]) )
 {
 print 'trtd colspan=2 style=font-weight:bold;Full
match(es):/td/tr'.
   'trtd colspan=2nbsp;/td/tr';

 if( !is_array($matches[0]) )
 {
 print 'tr'.
   'td width=25 style=font-weight: bold;1/td'.\n.
   'td'.htmlentities($matches[0]).'/td'.
   'tr/';
 }
 else
 {
 foreach($matches[0] as $key = $val)
 {
 print 'td width=25 style=font-weight: bold;'.($key+1).
   '/td'.\n.'td'.htmlentities($val).'/td'.\n.
   '/tr';
 }
 }
 }
 {
 print 'trtdspan style=color: lime; font-weight: bold;'.
   'No matches found./span/td/tr';
 }
 ( isset($matches[1])  !empty($matches[1]) )
 {
 print 'tr width=100%td colspan=2nbsp;/td/tr'.
   'tr width=100%td colspan=2hr//td/tr'.
   'tr width=100%td colspan=2nbsp;/td/tr'.
   'tr width=100%td colspan=2 style=font-weight:bold;'.
   'Sub-pattern match(es):/td/tr'.
   'tr width=100%td colspan=2nbsp;/td/tr';
 for($i = 1; $i  count($matches); $i++)
 {
 if( !is_array($matches[$i]) )
 {
 print 'tr width=100%'.
   'td width=25 style=font-weight:
 bold;'.$i.'/td'.\n.
   'td'.htmlentities($matches[$i]).'/td'.
   '/tr';
 }
 else
 {
 foreach($matches[$i] as $key = $val)
 {
 print 'tr width=100%'.
   'td width=25 style=font-weight:
 bold;'.$i.'.'.($key+1).
   '/td'.\n.'td'.htmlentities($val).'/td'.\n.
   '/tr';
 }
 }
 if( isset($matches[$i+1]) )
 {
 print 'tr width=100%td colspan=2nbsp;/td/tr';
 }
 }
 }
 ?
 /table
 /div
 /body
 /html

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



[PHP] Re: Regular expression help?

2004-02-02 Thread Matthew Weier O'Phinney
* Jas [EMAIL PROTECTED]:
 Not sure if anyone knows of a good way to match strings of this type...
 00:02:8b:0c:2f:09

 I have tried this but its not working.

 !eregi(^[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}$,$_POST['mac'])

Use the perl compatible regexps instead:

!preg_match('/^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$/', $_POST['mac'])

This searches for XX: 5 followed by XX, where XX is 0-9, A-F, or a-f. I
_think_ the POSIX regexps can do some grouping like this as well, but
I'm not absolutely sure.

-- 
Matthew Weier O'Phinney
Webmaster and IT Specialist
National Gardening Association
802-863-5251 x156
mailto:[EMAIL PROTECTED]
http://www.garden.org
http://www.kidsgardening.com

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



[PHP] Re: Regular Expression

2003-07-08 Thread SLanger
Hello

If you simply want to check if the fields contains Po BOX simply use the 
stripos function or one of the other string functions. They should be 
faster than reg ex.
If you still want to use reg ex I suggest using preg_match since it is 
faster than ereg. 
About your regex:
It will not find occurences of PO BOX in the field. You'd have to use 
something like ereg('PO BOX') without start anchor  '^' or end anchor '$'. 
I think eregi would be better since it is case insensitive.

It seems to me that you don't understand regular expressions so I suggest 
you do some reading up on them.
A very good book about regex is Mastering Regular Expression by O'Reilly 
can't remember the author right now sorry. 

Regards
Stefan Langer

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



[PHP] Re: Regular Expression Help in my PHP! Sorry if wrong group

2003-01-15 Thread Jason Lehman
I figured out what I was doing wrong.  My regexp should of looked like 
this /a[^]*(Tampa)\/a/ and that made it more specific and kept it 
to that match.

Jason Lehman wrote:
I have a script that turns certain words into links.  That I am having 
no problems with, it is when I want to turn the links back in to plain 
text that I am having the problem.  Below are my examples.  And I know 
my regex is being greedy but I don't know how to stop it from being so 
damn greedy I thought the ? mark would help but it didn't. Any help 
would be appreciated. So here it goes:


The code:

$strStr = This is a href=testUSF/a at a href=testTampa/a.  This 
is a href=testUSF/a at a href=testTampa/a.;
echo $strStr.br\n;
$strStr = preg_replace(/a.*?(Tampa)\/a/,\\1,$strStr);
echo $strStr.br\n;
$strStr = preg_replace(/a.*?(USF)\/a/,\\1,$strStr);
echo $strStr.br\n;

The output:

This is a href=testUSF/a at a href=testTampa/a. This is a 
href=testUSF/a at a href=testTampa/a.
This is Tampa. This is Tampa.
This is Tampa. This is Tampa.

The expected output:

This is a href=testUSF/a at a href=testTampa/a. This is a 
href=testUSF/a at a href=testTampa/a.
This is a href=testUSF/a at Tampa. This is a href=testUSF/a at 
Tampa.
This is USF at Tampa. This is USF at Tampa.



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




[PHP] Re: regular expression

2002-10-15 Thread Ns_Andy

perl: preg_match
'/a\s*href/s*=/s*[\']?[^\']+[\']?/i'

or eregi
'a[ ]*href[ ]*=[ ]*[\']?[^\']+[\']?'


--
Regards,

Noodle Snacks [EMAIL PROTECTED] wrote in message 
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 what would be a simple regular expression for a href=anythinghere?

 for future reference are there any good references for them?


 --
 JJ Harrison
 [EMAIL PROTECTED]





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




[PHP] Re: regular expression

2002-10-15 Thread Noodle Snacks

Thanks.


Ns_andy [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 perl: preg_match
 '/a\s*href/s*=/s*[\']?[^\']+[\']?/i'

 or eregi
 'a[ ]*href[ ]*=[ ]*[\']?[^\']+[\']?'


 --
 Regards,

 Noodle Snacks [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  what would be a simple regular expression for a href=anythinghere?
 
  for future reference are there any good references for them?
 
 
  --
  JJ Harrison
  [EMAIL PROTECTED]
 
 





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




[PHP] Re: Regular expression question

2002-08-30 Thread Philip Hallstrom

$str = jeD1GLal;
$str = ereg_replace([1LIO0lio], , $str);

something like that...

On Fri, 30 Aug 2002, Jeff Lewis wrote:

 Is there a regular expression that will remove 1, L, I, O, 0 and the
 lowercase equivilants from a varialbe?

 I am not horribly well versed in regular expressions...so I'm basically
 asking someone to help :)

 Say I have a string like this jeD1GLal

 I want to remove any of the chracters that be confusing ...

 Jeff


 --
 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: Regular expression for correcting proper nouns

2002-07-17 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Henry) wrote:

 I'm looking for a simple was to correct a list of proper nouns given all in
 lower case!
 
 For example
 
 given $string=london paris rome;
 
 I would like London Paris Rome.
 
 However there is one cavet; if the word already has a captital anywhere in
 it, it should be left alone!!!
 
 Is there a soultion using regular expressions?

Yes.  The topics you'll want to look at (in the PCRE chapter of the manual) 
are: case-sensitivity, character classes, capturing subpatterns, and the 
documentation for preg_replace_callback().  One of the things you'll need 
to do is define for yourself what constitutes a word for your purposes.  
Does a single letter word get counted as a word (i.e. i)?  Is there any 
non-alphabet character that can validly appear within the thing you call a 
word (i.e. hi-fi, mst3k)?  This is why there's no single ready-made 
solution.

 Also is there one for removing multiple spaces?
 
 i..e given A   B C D E it would give A B C D E.

Yes.  Again, character classes will be your friend, as will preg_replace().  
Just decide which of the whitespace characters you mean to include in that 
definition of multiple spaces...

-- 
CC

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




[PHP] Re: Regular Expression

2002-01-02 Thread Joe Webster

preg_match(/body\s([^]*)/i, $html, $args);
$body_props = $args[1];

preg is much faster/better than ereg.
note the /i at the end of the preg, that makes it case insative, drop the i
if you want it to be case sensative on the match.

-Joe

John Monfort [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 Hello everyone!

 I'm trying to get the text inside the BODY tag, using regular
 expression.

 $area = eregi('(body)(.*))',$str);

 Where $str is the string containing
 body bgcolor=#99 tex=#... ...

 When I print  $area, the string contains the entire content of $str. I
 get something like:

 body ...
 p
 .
 .
 .
 /body
 /html



 __John Monfort_
 _+---+_
  P E P I E  D E S I G N S
www.pepiedesigns.com
 The world is waiting, are you ready?
 -+___+-





-- 
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: Regular Expression

2001-11-13 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Adam Whitehead) wrote:

 if ((ereg([^[:alnum:]],$fn)) || (ereg([^[:alnum:]],$sn))) {
 // Do something here
 }
 
 What it's doing is checking two variables to make sure they contain only 
 alphanumeric characters.
 
 I have a requirement that hyphens (-) be allowed in $fn and $sn as well. 
 What do I need to add to the regular expression to allow hyphens?

Insert it as the last item in the character class:

[^[:alnum:]-]

-- 
CC

-- 
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: regular expression

2001-11-01 Thread liljim

Hello,

Galkov Vladimir [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Need to remove all ../   /..  from user inputing string to prevent him
 walking and creating filesdirectories where I don't whant see them/him...

 The string:

  $path =
 eregi_replace('([..]{2,})|([./]{2})|([../]{3,})|([/.]{2})|([/..]{3})', '',
 $path);

 works good with any  combinations ( ../../..qwert.txt  =  qwert.txt)
untill
 somth like /../asd/../qwert.txt will be entered ...
(/../asd/../qwert.txt
 = asdqwert.txt).
  So the qwestion is how upgrade regular expression to remove all this
 correctly (with all entered directory names but NOT assigned their names
to
 file name...

  Must do the operation:
  /../asd//qwert.txt  = qwert.txt
 but  not  = /asd/qwert.txt or asdqwert.txt.ru
 or
 /../asd/../qwert.txt.ru  = qwert.txt.ru
 but  not  = /asd/qwert.txt.ru or asdqwert.txt.ru


Try this:

?

$string = /../asd//qwert.txt;

$string = preg_replace(/(\.*\/\.?)+.*?(\.*\/)?/s, , $string);

echo $string;

?

May need some tweaking, let me know.

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




[PHP] Re: regular expression

2001-11-01 Thread liljim

Whooops,

Pasted wrong line.  This should do it:

$string = preg_replace(/(\.*\/)+(.*?\.*\/)?/s, , $string);

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]




[PHP] Re: regular expression

2001-11-01 Thread liljim

 Whooops,

 Pasted wrong line.  This should do it:

 $string = preg_replace(/(\.*\/)+(.*?\.*\/)?/s, , $string);

Gah... Not.. enough... caffeine: Modification:

$string = preg_replace(/(\.*\/)+(.*?\.*\/)?(\.*)?/s, , $string);



-- 
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: regular expression help

2001-09-18 Thread _lallous

This should do (but ofcourse you might want to play a bit with it)

$mem =
'
A HREF=http://www.mydomain.com/mypage.php;something/a is fine
A HREF=http://www.yourdomain.com/yourpage.php;something/a is wrong
A HREF=http://www.yourdomain.com/yourpage.php;something/a is finebr
a href=http://www.lgwm.org/;lgwm/abr
a href=http://www.google.com;
onclick=javascript:alert(\'hello\');Google!/a
';

function handler($theTag, $theDomain)
{
  if (!strstr($theDomain, mydomain.com))
  {
$theTag = strstr($theTag,  );
$theTag = a target='_blank'$theTag;
  }
  return stripslashes($theTag);
}

$re = /\s*a\s*href\s*=\s*(['\])(.+?)\\1[^]*/eis;
$t = preg_replace($re, handler('\\0', '\\2') ,$mem);
echo $t;

//greetings RZe!

Justin French [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 hi all,

 I have some user-supplied text on a content driven site.
 I am allowing A tags inside the main text, BUT I want
 any links to external sites (not on the chosen domain)
 to include a ' TARGET=_new ' element.

 So,

 A HREF=http://www.mydomain.com/mypage.php;something/a is fine
 A HREF=http://www.yourdomain.com/yourpage.php;something/a is wrong
 A HREF=http://www.yourdomain.com/yourpage.php;
 TARGET=_newsomething/a is fine

 And of course there are all the variants with and without
 the www, and with and without sub directories and pages.

 I'[d also like to make sure the dopey people have put a
 close tag in.


 I've got a few ideas on how it might be done, but I need
 to do it the right way, avoiding slight human errors etc.


 Has anyone got something written, or can point me in the
 right direction?


 Justin French



-- 
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: Regular Expression ? from newbie

2001-09-12 Thread _lallous

here's your PHP code,

?
$mem = '
table cellspacing=2 cellpadding=2 border=1
tr
td align=centerbanana/td
td align=left.46/td
td align=right.55/td
/tr

tr
td align=centerpear/td
td align=left.38/td
td align=right.51/td
/tr

tr
td align=centerapple/td
td align=left.59/td
td align=right.33/td
/tr
/table';

$re2 =
/.*?tr[^]*.*?td[^]*(.+?)\/td.*?td[^]*(.+?)\/td.*?td[^]*(.+?
)\/td.*?\/tr/is;
$re1 = '/table cellspacing=2 cellpadding=2
border=1(.+?)\/table/is';

if (preg_match($re1, $mem, $matches))
{
  if (preg_match_all($re2, $matches[1], $tddata, PREG_SET_ORDER))
  {
for ($i=0;$icount($tddata[0])-1;$i++)
{
  echo name={$tddata[$i][1]} p1={$tddata[$i][2]}
p3={$tddata[$i][3]}\n;
}
  }
}
?


Craig Westerman [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Consider the following table that I grabbed from another web site using:

 ?
 $url = 'http://www.abc123xyz.com';
 $lines_array = file($url);
 $lines_string = implode('', $lines_array);
 ?

 ===

 table cellspacing=2 cellpadding=2 border=0
 tr
 td align=centerbanana/td
 td align=left.46/td
 td align=right.55/td
 /tr

 tr
 td align=centerpear/td
 td align=left.38/td
 td align=right.51/td
 /tr

 tr
 td align=centerapple/td
 td align=left.59/td
 td align=right.33/td
 /tr
 /table

 ===

 The fruit lables don't change, but prices change daily.
 How would I parse JUST the two prices to the right of the word pear into a
 new html table?

 How would I parse the word pear AND the two prices to the right into a new
 html table?

 I think the answers will help me understand better.

 Thanks

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




[PHP] Re: Regular Expression Problem and PHP 4 (urgent)

2001-08-15 Thread Ross Nielsen

Actually I didn't pose my question correctly.
I also needed to grep out the Link for use in JS during the process.
I wrapped this in a class file and here is the entry that I ended up with.
Thanks for the assist though...
==
function getPL($plric)
  {
//variable set to add at the end of the RIC if it's a stock not a page
   $temp = B2;
//find out if it's a stock by query for the period in the RIC
   if (eregi(\., $plric))
   {
//add B2 if it's a stock
$plric = $plric + $temp;
   }
//the data comes out of the server pipe delimited
   $pages = split(\|,`/mdsweb/cgi-bin/Snap_Pages -s 000.000.000.00 -p
34927 -r $plric`);

   $a=0;
   while ($pages[$a] != )
   {
$pages[$a] = htmlentities($pages[$a]);
//replace spaces with nbsp;
$pages[$a] = str_replace( , nbsp;, $pages[$a]);
//find the left angle brackets
$a1 = spliti(lt;, $pages[$a]);
$b=0;
while ($a1[$b] != )
{
//if the resulting data has a right angle bracket
 if (eregi(gt, $a1[$b]))
 {
  $a2 = spliti(gt;, $a1[$b]);
  if (eregi(\., $a2[0]))
  {
   echo a class='small'
href='http://server/php/QST/PageTest.php?plric=;;
//this would be the raw RIC
   echo $a2[0],$tag;
//put back the left angle bracket in the link
   echo 'lt;;
   echo $a2[0];
//put back the right angle bracket in the link
   echo gt;/a;
   $c=1;
   //echo the link itself
while ($a2[$c])
   {
echo $a2[$c];
$c++;
   }
  }
  else
  {
   echo a class='small'
href='http://server/php/QST/PageTest.php?plric=;;
//this would be a Page request not a RIC
   echo $a2[0];
   echo ';
   echo $a2[0];
   echo /a;
   $c=1;
   while ($a2[$c])
   {
echo $a2[$c];
$c++;
   }
  }
 }
 else
 {
  echo $a1[$b];
 }
$b++;
}
   echo br;
   $a++;
   }
  }


Richard Lynch [EMAIL PROTECTED] wrote in message
00a001c1253f$53fad780$6401a8c0@Lynchux100">news:00a001c1253f$53fad780$6401a8c0@Lynchux100...
  blah blah blah blah blah Link blah blah blah blah Link
 
  I think I need to use eregi_replace to make the line look like this:
  blah blah blah blah blah a href='#'Link/a blah blah blah blah a
  href='#'Link/a

 Depending on how accurately you have stated the problem, this may work:

 $text = 'blah blah blah blah blah Link blah blah blah blah Link';
 $text = str_replace('', a href='#'XX, $text);
 $text = str_replace('', /a, $text);
 $text = str_replace('XX', '', $text);

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





-- 
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: Regular Expression Problem and PHP 4 (urgent)

2001-08-14 Thread Richard Lynch

 blah blah blah blah blah Link blah blah blah blah Link

 I think I need to use eregi_replace to make the line look like this:
 blah blah blah blah blah a href='#'Link/a blah blah blah blah a
 href='#'Link/a

Depending on how accurately you have stated the problem, this may work:

$text = 'blah blah blah blah blah Link blah blah blah blah Link';
$text = str_replace('', a href='#'XX, $text);
$text = str_replace('', /a, $text);
$text = str_replace('XX', '', $text);

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



-- 
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: Regular Expression help

2001-06-30 Thread J Smith

Clayton Dukes wrote:

 Okay, here's what I have so far:
 
 ---snip---
 if ((!$email)
|| ($email==)
|| (!eregi(^[_\.0-9a-z-]+@domain.+[a-z],$email))
)
 $stop = center._ERRORINVEMAIL./centerbr;
 ---snip---
 
 This works, but how can I add a second domain?
 ie:
 

Try:

^[_\.0-9a-z-]+@(domainA|domainB|etc)\.[a-z]{2,3}$

A complete email address check is insanely hard to to if you want to get 
RFC 822 compliant-checking, but who needs that anyways? (fwiw, the regex in 
Mastering Regular Expressions for checking email address syntax is some 
4,700 bytes long.)

J

-- 
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: Regular Expression help

2001-06-30 Thread Brad Hubbard

On Fri, 29 Jun 2001 23:43, Clayton Dukes wrote:
 Okay, here's what I have so far:

 ---snip---
 if ((!$email)

|| ($email==)
|| (!eregi(^[_\.0-9a-z-]+@domain.+[a-z],$email))

)
 $stop = center._ERRORINVEMAIL./centerbr;
 ---snip---

 This works, but how can I add a second domain?

How 'bout;

---snip---
 if ((!$email)
|| ($email==)
|| (!eregi(^[_\.0-9a-z-]+@domain|otherdomain.+[a-z],$email)

)
 $stop = center._ERRORINVEMAIL./centerbr;
---snip---

Cheers,
Brad
-- 
Brad Hubbard
Congo Systems
12 Northgate Drive,
Thomastown, Victoria, Australia 3074
Email: [EMAIL PROTECTED]
Ph: +61-3-94645981
Fax: +61-3-94645982
Mob: +61-419107559

-- 
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: Regular Expression help

2001-06-29 Thread Clayton Dukes

Okay, here's what I have so far:

---snip---
if ((!$email)
   || ($email==)
   || (!eregi(^[_\.0-9a-z-]+@domain.+[a-z],$email))
   )
$stop = center._ERRORINVEMAIL./centerbr;
---snip---

This works, but how can I add a second domain?
ie:

---snip---
if ((!$email)
   || ($email==)
   || (!eregi(^[_\.0-9a-z-]+@domain.+[a-z],$email))
   || (!eregi(^[_\.0-9a-z-]+@otherdomain.+[a-z],$email))
   )
$stop = center._ERRORINVEMAIL./centerbr;
---snip---

This doesn't work. (it returns the error no matter what I enter)

Thanks guys (and gals?)

Clayton Dukes
CCNA, CCDA, CCDP, CCNP
Download Free Essays, Term Papers and Cisco Training from http://www.gdd.net


- Original Message -
From: Clayton Dukes [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, June 29, 2001 9:08 AM
Subject: Regular Expression help


 Hi everyone,

 I have a new user function that checks e-mail addresses.
 I wish to only allow people from two different domains to register.
 How can I filter out all other e-mail addresses and return an error if
it's
 not from those domains.

 Here's what I have:

 if ((!$email) || ($email==) ||
 (!eregi(^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$,$email)))
$stop
 = center._ERRORINVEMAIL./centerbr;

 What this currently does is just makes sure it's a valid e-mail address.
 What I'd like it to do is if the user enters anything except @domain1.com
or
 @domain2.com it spits out the error (ERRORINVEMAIL)

 So (I think) It would look something like this:

 if ((!$email) || ($email==) || (!eregi(^[_\.0-9a-z-]+@([DdOoMmAaIiNn1]
||
 (or statement???) [DdOoMmAaIiNn2-]+\.)+[a-z]{2,3}$,$email))) $stop =
 center._ERRORINVEMAIL./centerbr;


 Of course, this doesn't work, but you get the point.


 Thanks!
 P.S.
 Thanks for the Awesome List!

 Clayton Dukes
 CCNA, CCDA, CCDP, CCNP
 Download Free Essays, Term Papers and Cisco Training from
http://www.gdd.net






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