Another alternative is to use LINQ:

string.Join("", text.Where(x => x != '?'))

It's probably not the most straight forward way of doing it, but it does allow 
a lambda to be used to filter on the characters of a string, which `Replace` 
and `Regex` do not.

From: [email protected] [mailto:[email protected]] On 
Behalf Of Ian Thomas
Sent: Friday, 7 June 2013 09:56
To: 'ozDotNet'
Subject: RE: regex - how to remove questionmark

Thanks for all 3 suggestions. The string replace is fine for such a simple 
case, which I had decided – and as Greg K also points out. But regex.escape is 
what I was after (for use elsewhere,  simplifying more complex string handling).

________________________________
Ian Thomas
Victoria Park, Western Australia

From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]] On Behalf Of 
[email protected]<mailto:[email protected]>
Sent: Thursday, June 06, 2013 8:53 PM
To: ozDotNet
Subject: RE: regex - how to remove questionmark

place it in a character class [?]

--------- Original Message ---------
Subject: regex - how to remove questionmark
From: "Ian Thomas" <[email protected]<mailto:[email protected]>>
Date: 6/6/13 6:35 am
To: [email protected]<mailto:[email protected]>
I am confusing myself in trying to use regular expression to remove a 
questionmark, which may be anywhere in a string. Can someone give me the right 
way?

________________________________
Ian Thomas
Victoria Park, Western Australia

Reply via email to