Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: why doesnt my regex doesnt matches certain character?

by Anonymous Monk
on May 11, 2005 at 10:32 UTC ( [id://455937]=note: print w/replies, xml ) Need Help??


in reply to Re: why doesnt my regex doesnt matches certain character?
in thread why doesnt my regex doesnt matches certain character?

Hi Pelagic

I cant copy the sample input. The character appears as ''. I want to match this character in my regex

Thanks in advance

A M Angelo

  • Comment on Re^2: why doesnt my regex doesnt matches certain character?

Replies are listed 'Best First'.
Re^3: why doesnt my regex doesnt matches certain character?
by thundergnat (Deacon) on May 11, 2005 at 10:51 UTC

    Those are control characters of some type. That particular one is "Delete" - character \x7F. Assuming they are all the same, you can match against that. It might be better to match against a character class though, in case they vary.

    Try:

    $text =~ /\p{Control}/;

    to match, or

    $text =~ s/\p{Control}//g;

    to remove.

Re^3: why doesnt my regex doesnt matches certain character?
by Forsaken (Friar) on May 11, 2005 at 10:53 UTC
    The trick is to determine the ascii value of the character. Once you have that you can take its octal value and use ie \035 to match for it, where /s/035/the octal value of that character/. An entirely different approach, although far less likely to work is to simply use . which will match 1 character, regardless of what it is. Ofcourse this depends very heavily on whether the text you're trying to match has a specific order or not.

    Remember rule one...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://455937]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-24 08:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found