Hi Sam - yes, the \\ was my mis-remembering (I tried one \ which of course is no good). And the .Escape() method also escaped me.
I had another regex difficulty (I'm hopelessly slow working out these), to remove the extra zero from every matching line in a subrip (.SRT subtitle) file - In the following, the ,7600 should be ,760 and the ,5200 should be ,520 (etc) 0 00:00:01,7600 --> 00:00:05,5200 For many, the 1950s were the golden age of British motoring. 1 00:00:05,7200 --> 00:00:10,8400 Back then, driving was leisurely, liberating and fun. 2 Being impatient, I used strings methods. I'm sure regex is at least 10 times more concise, but it would have taken me a couple of hours to work out the syntax! ________________________________ Ian Thomas Victoria Park, Western Australia -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Sam Lai Sent: Saturday, June 08, 2013 12:10 PM To: ozDotNet Subject: Re: regex - how to remove questionmark You might have forgotten to add an @ in front of the string to preserve the escape for the regexp engine. Alternatively, you could use two slashes instead to escape the escape character so it reaches the regexp engine. string exp1 = @"\?"; or string exp2 = "\\?"; On 6 June 2013 21:07, Ian Thomas < <mailto:[email protected]> [email protected]> wrote: > Yes, string.replace is good enough - there wouldn't be much processing > penalty in what I'm doing. > > It's just annoying that I can't remember (or even find) how to do this in > regex - I thought just escaping \ the ? would be the way. > > > > ________________________________ > > Ian Thomas > Victoria Park, Western Australia
