Regular expression to delete from a string unseen characters

--=__Part48647BAA.0__=
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable




Hi,

I have a data that contain unseen characters that I want to delete.
The unseen characters can be ^L, ^N and other sign that I cannot copy =
but I see them in my data.

Is someone know which regular can help me.
Shlomit.

--=__Part48647BAA.0__=--
Shlomit Afgin [ So, 06 März 2011 17:22 ] [ ID #2056259 ]

Re: Regular expression to delete from a string unseen characters

>
> I have a data that contain unseen characters that I want to delete.
> The unseen characters can be ^L, ^N and other sign that I cannot copy but I
> see them in my data.
>
> Is someone know which regular can help me.


May you try the "dos2unix" command?


--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
terry peng [ Mo, 07 März 2011 12:17 ] [ ID #2056261 ]

Re: Regular expression to delete from a string unseen characters

On 06/03/2011 16:22, Shlomit Afgin wrote:
>
> I have a data that contain unseen characters that I want to delete.
> The unseen characters can be ^L, ^N and other sign that I cannot
> copy but I see them in my data.
>
> Is someone know which regular can help me.

Hi Shlomit.

It would be better to list the specific characters that you want to
remove, but you could get away with the POSIX character class [:cntrl:].
A substitution like

s/[[:cntrl:]]+//g

would remove all control characters (ordinals 0..31 and 127). A more
efficient way would be to avoid regular expressions and use tr///:

tr/\x00-\x1F\x7F//d;

HTH,

Rob

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Rob Dixon [ Mo, 07 März 2011 12:19 ] [ ID #2056262 ]

Re: Regular expression to delete from a string unseen characters

On 2011-03-06 17:22, Shlomit Afgin wrote:

> I have a data that contain unseen characters that I want to delete.
> The unseen characters can be ^L, ^N and other sign that I cannot copy but I see them in my data.
>
> Is someone know which regular can help me.

See perldoc perlre, specifically [:cntrl:].

Try for example:

s/[[:cntrl:]]/_/g

or alternatively:

s/[\x00-\x1F]/_/g

--
Ruud


--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
rvtol+usenet [ Mo, 07 März 2011 12:15 ] [ ID #2056312 ]
Perl » gmane.comp.lang.perl.beginners » Regular expression to delete from a string unseen characters

Vorheriges Thema: Auto correction of typos
Nächstes Thema: about perl -wl