By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,710 Members | 1,906 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,710 IT Pros & Developers. It's quick & easy.

Perl Regular Expression

P: 40
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.

Expand|Select|Wrap|Line Numbers
  1. $word = "Baal·bek";
  3. if($word=~m#·#)
  4. {
  5. print "Match found";
  6. }
  7. else
  8. {
  9. print "Not Match found";
  10. }
while running above script it prints "Not Match Found".

whats arong in this code.

thanks in advance
May 6 '09 #1
Share this Question
Share on Google+
2 Replies

P: 40

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
Expand|Select|Wrap|Line Numbers
  1. open(FR, "<$FilePath");
and its not works when I read a file data using utf-8 format
Expand|Select|Wrap|Line Numbers
  1. open(FR, "<:utf8", "$FilePath");
Can anyone guide me regarding this.
May 6 '09 #2

Expert Mod 2.5K+
P: 3,503
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.


May 13 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.