Re: regular Expression
by Transient (Hermit) on Jun 28, 2005 at 14:16 UTC
|
| [reply] [d/l] |
|
|
| [reply] [d/l] |
|
|
Sure, unless you're using Unicode.
| [reply] |
Re: regular Expression
by Ido (Hermit) on Jun 28, 2005 at 14:20 UTC
|
You could use the POSIX character class:
/[:^ascii:]/. Check perlre. | [reply] [d/l] |
|
|
/[^[:ascii:]]/g
or
/[[:^ascii:]]/g
(Update: check perlre) | [reply] [d/l] [select] |
Re: regular Expression
by ghenry (Vicar) on Jun 28, 2005 at 14:17 UTC
|
Have a read through the regular expression Tutorials
Walking the road to enlightenment... I found a penguin and a camel on the way.....
Fancy a yourname@perl.me.uk? Just ask!!!
| [reply] |
Re: regular Expression
by fmerges (Chaplain) on Jun 28, 2005 at 14:28 UTC
|
Hi,
Once you get familiar with regular expressions, take a look at Regexp::Common
Regards,
:-)
| [reply] |
Re: regular Expression
by ikegami (Patriarch) on Jun 28, 2005 at 15:15 UTC
|
If you meant non-ASCII characters and non-displayable ASCII characters, then use /[^\x20-\x7E]/.
| [reply] [d/l] |
|
|
| [reply] [d/l] |
Re: regular Expression
by l.frankline (Hermit) on Jun 29, 2005 at 15:09 UTC
|
try
$_ =~ /[^\w\d\s]+/;
* Frank * | [reply] [d/l] [select] |
Re: Regular expression
by emav (Pilgrim) on Jun 29, 2005 at 10:37 UTC
|
/[^!-~\s]/g
| [reply] [d/l] |
|
|
That doesn't really do what the original poster asked for tho' does it? Ascii characters are those with a character code between 0 and 128. Your code only checks for character codes between 33 and 126 (plus a few whitespace characters).
To match _all_ non-ascii characters you really need something like:
/[^\x00-\x7f]/
--
< http://www.dave.org.uk>
"The first rule of Perl club is you do not talk about
Perl club." -- Chip Salzenberg
| [reply] [d/l] |
|
|
Marvellous!It works Fine but pls explain me emav
| [reply] |
|
|
^ = exclude
!-~ = all characters between ! and ~
\s = or spaces
g = search globally
As davorg has pointed out, mine is a rough regex but I use it often to find non-English characters in my xml files, as it not only works embedded in a perl script but also with editors that use perl-based regex's such as my favourite Unired.
| [reply] |