Hello:
I have a string, "Testing_!@#$%^&*()". It may have single and double
quotations as well.
I would like to strip all chararcters others than a-z, A-Z, 0-9 and the comma.
I came across the following snippet in the online help but the output does
not change at all:
Function CleanInput(ByRef strIn As String) As String
'returns a string after stripping out all nonalphanumeric characters
except @, - (a dash), and . (a period).
' Replace invalid characters with empty strings.
Return Regex.Replace(strIn, "[^\w\.@-]", "")
End Function
So if I pass in a string, "Testing_!@#$%^&*()", I get the same back.
Any help will be appreciated.
Thanks.
Venki 4 3004
While I was waiting, I was able to figure it out.
with the regex string, "[`~!@#$%^&*()_\-=+\[\]\{\}\|;:'./<>?\b\t ]" I was
able to strip out all unwanted characters except a-z, A-Z, 0-9, comma, double
quote.
Venki
"vvenk" wrote:
Hello:
I have a string, "Testing_!@#$%^&*()". It may have single and double
quotations as well.
I would like to strip all chararcters others than a-z, A-Z, 0-9 and the comma.
I came across the following snippet in the online help but the output does
not change at all:
Function CleanInput(ByRef strIn As String) As String
'returns a string after stripping out all nonalphanumeric characters
except @, - (a dash), and . (a period).
' Replace invalid characters with empty strings.
Return Regex.Replace(strIn, "[^\w\.@-]", "")
End Function
So if I pass in a string, "Testing_!@#$%^&*()", I get the same back.
Any help will be appreciated.
Thanks.
Venki
Hello:
I also wanted to strip out any double quotes. So I changed the regex to
"[`~!@#$%^&*()_\-=+\[\]\{\}\|;:'./<>?\b\t \34]"
since I cannot embed a double quote within a string in VB (or at least I do
not know how to.)
But this does not strip the double quotes. I checked the above with
RegexBuddy and it works with it.
Thanks
venki
"vvenk" wrote:
While I was waiting, I was able to figure it out.
with the regex string, "[`~!@#$%^&*()_\-=+\[\]\{\}\|;:'./<>?\b\t ]" I was
able to strip out all unwanted characters except a-z, A-Z, 0-9, comma, double
quote.
Venki
"vvenk" wrote:
Hello:
I have a string, "Testing_!@#$%^&*()". It may have single and double
quotations as well.
I would like to strip all chararcters others than a-z, A-Z, 0-9 and the comma.
I came across the following snippet in the online help but the output does
not change at all:
Function CleanInput(ByRef strIn As String) As String
'returns a string after stripping out all nonalphanumeric characters
except @, - (a dash), and . (a period).
' Replace invalid characters with empty strings.
Return Regex.Replace(strIn, "[^\w\.@-]", "")
End Function
So if I pass in a string, "Testing_!@#$%^&*()", I get the same back.
Any help will be appreciated.
Thanks.
Venki
"vvenk" <vv***@discussions.microsoft.comschrieb:
Function CleanInput(ByRef strIn As String) As String
'returns a string after stripping out all nonalphanumeric
characters
except @, - (a dash), and . (a period).
' Replace invalid characters with empty strings.
Return Regex.Replace(strIn, "[^\w\.@-]", "")
End Function
In addition to the other replies, pass 'strIn' as 'ByVal'. 'String' is a
reference type.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Herfriend:
I noticed that too. BTW, this is from the on-line help. Even after changing
it, the function, as it is written in the on-line help, does not work.
venki
"Herfried K. Wagner [MVP]" wrote:
"vvenk" <vv***@discussions.microsoft.comschrieb:
Function CleanInput(ByRef strIn As String) As String
'returns a string after stripping out all nonalphanumeric
characters
except @, - (a dash), and . (a period).
' Replace invalid characters with empty strings.
Return Regex.Replace(strIn, "[^\w\.@-]", "")
End Function
In addition to the other replies, pass 'strIn' as 'ByVal'. 'String' is a
reference type.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Eric Lilja |
last post by:
Hello, I had what I thought was normal text-file and I needed to locate a
string matching a certain pattern in that file and, if found, replace that
string. I thought this would be simple but I had...
|
by: SeaPlusPlus |
last post by:
I want to convert large files of prose to xhtml and so I need a way to
remove unwanted line wraps. So, I'm looking for a freebee editor that
has the capability of searching for a single "carriage...
|
by: M |
last post by:
Hi,
I've searched through the previous posts and there seems to be a few
examples of search and replacing all occurrances of a string with
another string.
I would have thought that the code...
|
by: o_swas |
last post by:
Hello,
I have a JavaScript string. I want to replace all consecutive
occurrences of whitespace characters like spaces, tabs, newlines, and
form feeds with another string.
For example, say I...
|
by: Art |
last post by:
What's the most efficient way to replace characters in an XML document before
it is loaded into a parser? Chars I'd want to replace are in attributes and
there can be N attributes, also let's...
|
by: lovecreatesbeauty |
last post by:
/*
When should we worry about the unwanted chars in input stream? Can we
predicate this kind of behavior and prevent it before debugging and
testing? What's the guideline for dealing with it?
...
|
by: Grok |
last post by:
I need an elegant way to remove any characters in a string if they are
not in an allowed char list. The part cleaning files of the
non-allowed characters will run as a service, so no forms here.
...
|
by: COHENMARVIN |
last post by:
I have a string with an unwanted unicode character. It looks like an
'A' with a tilde on top. I looked up a unicode chart on the internet
and the chart says that its represented by Â
So I think...
|
by: Alexey Smirnov |
last post by:
On Jul 10, 11:03 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
Sorry, the one with a tilde on top is Â
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |