Rob Dixon wrote: >Raja Kasinathan wrote: > > >>I have a pattern like s/\b\@interrupt\b//gi; This doesn't remove the >>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? >> >> > >Hi Raja. > >As Stefan says the \b isn't finding a 'word boundary', which >is a zero-width match between a 'word' character and a >'non-word' character. A word character is one which will >match the \w characters class, which is all numerics, upper >and lower case alphabetics and underscore. Since 'at' isn't in >this class there is unlikely to be a word boundary before it, >and you probably wouldn't want it to match if there was. > >If you want to make sure that the the regex doesn't find >something like 'rob.dixon@interrupt.co.uk' then force >it to be preceded with a non-word like this: > > s/(?<=\W)\@interrupt\b//gi > Except that this will not work when '@interrupt' occurs at the start of the line. '\W' is not a zero-width assertion and to match at the start of a line you will need one > >I hope this helps, > >Rob > > > > > >Thread Previous | Thread Next