Perl Regular Expression

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cnsabar
    New Member
    • Dec 2007
    • 40

    Perl Regular Expression

    Hi All,

    I facing a problem in matching flat character symbol.

    I cant able to find the · this character in the word.

    Here is my script.

    Code:
    $word = "Baal·bek";
    
    if($word=~m#·#)
    {
    print "Match found";
    }
    else
    {
    print "Not Match found";
    }
    while running above script it prints "Not Match Found".

    whats arong in this code.

    thanks in advance
    Last edited by numberwhun; May 13 '09, 07:04 PM. Reason: Please use code tags!
  • cnsabar
    New Member
    • Dec 2007
    • 40

    #2
    Hi,

    I found the solution. but do know why this is happening.

    The specified script works fine when I read a file Content using following syntax
    Code:
    open(FR, "<$FilePath");
    and its not works when I read a file data using utf-8 format
    Code:
    open(FR, "<:utf8", "$FilePath");
    Can anyone guide me regarding this.
    Last edited by numberwhun; May 13 '09, 07:06 PM. Reason: Please use code tags!

    Comment

    • numberwhun
      Recognized Expert Moderator Specialist
      • May 2007
      • 3467

      #3
      First, and I know this has been said in the past, please use code tags around all code that you place in your forum posts. It makes the post much easier to read. Thank you!

      As for your issue, what you are going to want to do is use the ASCII value of the character you are trying to match. To do so, you will have to use an escape sequence and the ascii value for the character you want to match.

      In this case, I believe 142 is the ascii sequence you wan to use.

      Regards,

      Jeff

      Comment

      Working...