Raja Kasinathan wrote:
>I have a pattern like s/\b\@interrupt\b//gi; This doesn't remove the
>
\b is a zero-width assertion that matches when there is \w (alphanumeric
plus '_') on the one side and a \W (complement of \w) on the other side
perldoc perlre
In your case you have a \W on both sides and the regexp does not match.
To explain it with an example
$_ = 'a@interrupt int func (int)'
s/\b\@interrupt\b//gi;
print;
The above code will print
a int func (inf)
The reason being you a have a \w ('a') and \W ('@') on either side and
\b matches.
If '@interrupt' will only occur at the start of the line you can do this
s/^\@interrupt\b//i;
If you want to replace it anywhere, this is one possible way
s/(^|\s)\@interrupt\b//gi;
I must admit that I have never used or seen other's use '^' in a '|'
with another pattern.
It seems to work, can one of the experts second me on this one
>word @interrupt.
>from my input data
>"@interrupt void interrupt_handler(void)"
>
>If I don't escape @, I get a warning "Possible unintended interpolation
>of @interrupt in string".
>Can anyone help me regarding this?
>
>Cheers,
>Raja
>
>
Thread Previous
|
Thread Next