List Info

Thread: Simple regex help




Simple regex help
user name
2006-11-27 21:12:19
Just wondering how to search a string for non word
characters that 
aren't spaces...
W is for a non-word character, s would find a space, just
wondering 
how to put that together in a regex...

Thanks much,

David


Unsubscribing info is here: h
ttp://help.yahoo.com/help/us/groups/groups-32.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://g
roups.yahoo.com/group/perl-beginner/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http
://groups.yahoo.com/group/perl-beginner/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:perl-beginner-digest@yahoogroups.com 
    mailto:perl-beginner-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    perl-beginner-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 
Simple regex help
user name
2006-11-27 21:29:13
>>>>> "da5id" == da5id 
<da5idt3rse.com> writes:

da5id> Just wondering how to search a string for non word
characters that 
da5id> aren't spaces...
da5id> W is for a non-word character, s would find a
space, just wondering 
da5id> how to put that together in a regex...

You can only "or" together in a char class (this
OR that).
But you want to "and".  Luckily, DeMorgan's laws
teaches us
that the following are equivalent:

        (this AND that)
        NOT (NOT this OR NOT that)

so it's just a matter of writing it out.  You want:

        (non-word AND non-space)

which demorgan says is:

        NOT (NOT non-word OR NOT non-space)

and reducing the nots:

        NOT (word OR space)

and writing that in regex talk:

        [ ^ w s ]

and removing the spacing:

        [^ws]

There ya go.  All the chars that are neither word nor space.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. -
+1 503 777 0095
<merlynstonehenge.com> <URL:http://www.ston
ehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy,
etc. etc.
See PerlTraining.Stonehenge.com for onsite and
open-enrollment Perl training!


Unsubscribing info is here: h
ttp://help.yahoo.com/help/us/groups/groups-32.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://g
roups.yahoo.com/group/perl-beginner/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http
://groups.yahoo.com/group/perl-beginner/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:perl-beginner-digest@yahoogroups.com 
    mailto:perl-beginner-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    perl-beginner-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )