php-general Digest 27 Jan 2013 09:10:33 -0000 Issue 8104

Topics (messages 320106 through 320113):

Re: Strip emails from a document
        320106 by: shiplu
        320107 by: Jonathan Sundquist
        320108 by: Tedd Sperling
        320109 by: shiplu
        320110 by: Tim Streater
        320111 by: Tedd Sperling
        320112 by: shiplu

What needs to configure to run php exec for socket connection?
        320113 by: jupiter

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
I think you meant extract emails from document, right?

I'd probably find `@` and iterate before and after unless I get posix
punct, space, characters.  But it'll probably give some false matches. So
its really hard to find 100% emails from an arbitrary text. This is because
valid email can contain many different type of characters. According to RFC
822 space is a valid character in email. So finding all the valid emails is
tough.
In a *trivial situation* an email would be separated by space. So find @
first. Then go back and front to find the first space. You'll get most
common emails. Something like using this regex pattern
[^[:space:]<@]+@[^[:space:]>]+ would suffice.
But keep in mind, it'll work on trivial cases. Not on special cases.
Regular expression can not be used on special cases. Here is full RFC-822
compliant email matching regular expression
http://ex-parrot.com/~pdw/Mail-RFC822-Address.html


More information can be found on
http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address


On Sat, Jan 26, 2013 at 10:24 PM, Tedd Sperling <t...@sperling.com> wrote:

> Hi gang:
>
> I thought I had a function to strip emails from a document, but I can't
> find it.
>
> So, before I start writing a common script, do any of you have a simple
> script to do this?
>
> Here's an example of the problem:
>
> Before:
>
> "Will Alex" <ale...@cit.msu.edu>;"Moita Zact" <za...@cit.msu.edu>;"Bob
> Arms" <ar...@cit.msu.edu>;"Meia Terms" <term...@cit.msu.edu>;
>
> After:
>
> ale...@cit.msu.edu
> za...@cit.msu.edu
> ar...@cit.msu.edu
> term...@cit.msu.edu
>
> Cheers,
>
> tedd
>
>
> _____________________
> t...@sperling.com
> http://sperling.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader

--- End Message ---
--- Begin Message ---
If you are expecting the email address to always be the same but the first
part being different you can create a regular expression to match it that
way. Using a regular expression over all is going to be your best bet as
shiplu suggested.


On Sat, Jan 26, 2013 at 10:54 AM, shiplu <shiplu....@gmail.com> wrote:

> I think you meant extract emails from document, right?
>
> I'd probably find `@` and iterate before and after unless I get posix
> punct, space, characters.  But it'll probably give some false matches. So
> its really hard to find 100% emails from an arbitrary text. This is because
> valid email can contain many different type of characters. According to RFC
> 822 space is a valid character in email. So finding all the valid emails is
> tough.
> In a *trivial situation* an email would be separated by space. So find @
> first. Then go back and front to find the first space. You'll get most
> common emails. Something like using this regex pattern
> [^[:space:]<@]+@[^[:space:]>]+ would suffice.
> But keep in mind, it'll work on trivial cases. Not on special cases.
> Regular expression can not be used on special cases. Here is full RFC-822
> compliant email matching regular expression
> http://ex-parrot.com/~pdw/Mail-RFC822-Address.html
>
>
> More information can be found on
>
> http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address
>
>
> On Sat, Jan 26, 2013 at 10:24 PM, Tedd Sperling <t...@sperling.com> wrote:
>
> > Hi gang:
> >
> > I thought I had a function to strip emails from a document, but I can't
> > find it.
> >
> > So, before I start writing a common script, do any of you have a simple
> > script to do this?
> >
> > Here's an example of the problem:
> >
> > Before:
> >
> > "Will Alex" <ale...@cit.msu.edu>;"Moita Zact" <za...@cit.msu.edu>;"Bob
> > Arms" <ar...@cit.msu.edu>;"Meia Terms" <term...@cit.msu.edu>;
> >
> > After:
> >
> > ale...@cit.msu.edu
> > za...@cit.msu.edu
> > ar...@cit.msu.edu
> > term...@cit.msu.edu
> >
> > Cheers,
> >
> > tedd
> >
> >
> > _____________________
> > t...@sperling.com
> > http://sperling.com
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> Shiplu.Mokadd.im
> ImgSign.com | A dynamic signature machine
> Innovation distinguishes between follower and leader
>

--- End Message ---
--- Begin Message ---
On Jan 26, 2013, at 12:20 PM, Daniel Brown <danbr...@php.net> wrote:
> 
>    It's imperfect, but will work for the majority of emails:
> 
> <?php
> function scrape_emails($input) {
>        
> preg_match_all("/\b([a-z0-9%\._\+\-]+@[a-z0-9-\.]+\.[a-z]{2,6})\b/Ui",$input,$matches);
>        return $matches;
> }
> ?>

It works imperfectly enough for me. :-)

Here's the result:

http://www.webbytedd.com/aa/strip-email/index.php

Thanks to all.

Cheers,

tedd

PS: Yes, 'extract" is what I meant and more correct than 'strip' as I said.

_____________________
t...@sperling.com
http://sperling.com

--- End Message ---
--- Begin Message ---
What is your input?



On Sat, Jan 26, 2013 at 11:29 PM, Tedd Sperling <t...@sperling.com> wrote:

>
> On Jan 26, 2013, at 12:20 PM, Daniel Brown <danbr...@php.net> wrote:
> >
> >    It's imperfect, but will work for the majority of emails:
> >
> > <?php
> > function scrape_emails($input) {
> >
>  
> preg_match_all("/\b([a-z0-9%\._\+\-]+@[a-z0-9-\.]+\.[a-z]{2,6})\b/Ui",$input,$matches);
> >        return $matches;
> > }
> > ?>
>
> It works imperfectly enough for me. :-)
>
> Here's the result:
>
> http://www.webbytedd.com/aa/strip-email/index.php
>
> Thanks to all.
>
> Cheers,
>
> tedd
>
> PS: Yes, 'extract" is what I meant and more correct than 'strip' as I said.
>
> _____________________
> t...@sperling.com
> http://sperling.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader

--- End Message ---
--- Begin Message ---
On 26 Jan 2013 at 16:24, Tedd Sperling <t...@sperling.com> wrote:

> I thought I had a function to strip emails from a document, but I can't find
> it.
>
> So, before I start writing a common script, do any of you have a simple script
> to do this?

I have a function that will take a comma separated string consisting of emails 
in these formats:

 "Soap, Joe" <joe.s...@example.com>
 Joe Soap  <joe.s...@example.com>
 (Joe Soap) joe.s...@example.com

and turn them into a list where all the above examples are converted to:

 Joe Soap  <joe.s...@example.com>

but it won't handle things like:

 "joe@soap"@example.com

which I understand is also valid.

You are welcome to it if you wish.

Cheers,

--
Cheers  --  Tim

--- End Message ---
--- Begin Message ---
On Jan 26, 2013, at 12:48 PM, shiplu <shiplu....@gmail.com> wrote:

> What is your input?
> 


Check my first email in this thread.

Cheers,

tedd


_____________________
t...@sperling.com
http://sperling.com


--- End Message ---
--- Begin Message ---
See this http://ideone.com/e1aM3E

-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader

--- End Message ---
--- Begin Message ---
Hi,

I  have a client.php which calls an external python socket client
program exec("Client.py"), the Client.py calls
sockobj.connect(("localhost", 60000)) to connect socket.

If I run the client.php from Linux command line $ ./client.php, it
works find, no problem at all.

But when I run it from web page http://localhost/client.php, it could
not connect to socket at following exception in python
sockobj.connect(("localhost", 60000)):

"sockobj.connect Errno 13 Permission denied"

Why it can run from command line, but cannot make socket connection
from web? Does it need some kind of configuration in php or apache?
Appreciate any tips and clues.

Thank you.

Kind regards.
I am puzzled by

--- End Message ---

Reply via email to