I need to detect µ sign in a texte but don't find how to indicate to the regular expression how to find the µ sign. Exemple of regular expression will be great !
As always, there are multiple ways of doing anything in informatics and so it happens in bioinformatics.
For this specific problem, you can use a regex function or you can use a predefined perl function named ord, that returns the ASCII code of any given symbol.
The ASCII code for µ symbol is 230 (http://www.theasciicode.com.ar/extended-ascii-code/lowercase-letter-mu-micro-sign-micron-ascii-code-230.html).
I am not sure why, in my case, µ is codified as 194, I guess it must be due to the encoding of my computer. Anyway, I will 194 as an identifier for the µ symbol.
Here I show you an implementation in perl of both, using regex and using perl ord and the 194 ASCII code
Imagine your data is in a file "test.txt" containing several lines like:
**************************
x=12
µ=12,13
**************************
Now, pass this file as an argument to a perl script containing the following code.
**************************
#!/usr/bin/perl
use strict;
use warnings;
my $file = $ARGV[0];
open("FILE", $file);
while () {
chomp;
my $line = $_;
print "READING: ".$line."\n";
if ($line =~ /.*µ.*/) { print "FOUND using regex!!\n"; }
my @array_line = split("=", $line);
for (my $i=0; $i < scalar @array_line; $i++) {
my $tmp = ord($array_line[$i]); ## ord: basic perl function: returns number given ASCII