From: "Jan E." Date: 2012-04-15T21:04:14+09:00 Subject: Re: how to avoid escaping special chars after backslah in string Lucky Nl wrote in post #1056566: > Now am using regular expression > > " \*\imp ".match(/ > [|@|#|$|+|{|}|'|"|?|<|>|*|-|!|%|^|&|:|;|\|=|.|~|`|^|\]|\[|'|\\|\/|\|]imp > /) > > > It is satisfying coniditions which i was expected . No, it doesn't. I've already said this in the answer you're are quoting. And I've already given you correct regexes which do what you want. However, you don't seem to care about our solutions (despite asking for them again and again). I find this a bit annoying. Test your regex with the string "abc****imp****xyz". This matches for the substring "*imp", although it definitely shouldn't. That's because you're not checking the surroundings of the string. Instead, you're searching for *any* substring consisting of a "special char" and the word "imp". Also note that the regex is too cumbersome, and the "|" inside the character class don't make any sense. Since I don't want to repeat everything I already said in your other threads, here are the links: http://www.ruby-forum.com/topic/3999160#1055090 (a solution for the "special chars") http://www.ruby-forum.com/topic/4038951#1055987 (a complete solution for the string matching) > Am expecting to allow word > only when it has single specialchar around that.But this is failing when > string contains \ No, that has nothing to do with backslashes, it's a problem of your regex (see above). But even if the backslashes *were* the problem: What do you want to do about it? Go on complaining about it forever? We've already given you solutions to the problem. Please, *read* the answers you get. Then you don't have to ask the same questions again and again. -- Posted via http://www.ruby-forum.com/.