[AccessD] Use Regex - Create Camel Case

Charlotte Foust cfoust at infostatsystems.com
Thu Sep 27 15:03:25 CDT 2007


The idea was to use RegEx to see if any processing was required on the
string.  If not, it saves a lot of time, since not every string will
have to be stepped through.  John was also struggling with Regex.  You
can do this if you want to process every string and if you don't need
the Ucase:

        Dim rex As System.Text.RegularExpressions.Regex
        ' the double backslash is required to indicate
        ' that the single backslash is a part of the pattern to search
        rex = New System.Text.RegularExpressions.Regex("[""'|\\/*?><~]",
_
                System.Text.RegularExpressions.RegexOptions.None)
        ' Replace invalid character with empty strings.
        Dim strOut As String = rex.Replace(strCompany, "") 

In this situation John might be better off using the approach you
suggested in actually handling the replacement. 

Charlotte Foust

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
max.wanadoo at gmail.com
Sent: Thursday, September 27, 2007 12:42 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Use Regex - Create Camel Case

Hi Charlotte,
I don't think this is what John wants.  He needs to camelcase it based
on the valid character following the invalid one.
I think that is what he wants - might be wrong.
Max
 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte
Foust
Sent: Thursday, September 27, 2007 8:30 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Use Regex - Create Camel Case

Here's a routine to determine if there are invalid characters in a
string using RegEx.  Maybe that will help.

   Private Function HasInvalidChars(ByVal strIn As String) As Boolean
        Dim strInvalid As String = "[""'|\\/*?><~]"
        Try
            Dim rex As System.Text.RegularExpressions.Regex
            ' the double backslash is required to indicate
            ' that the single backslash is a part of the pattern to
search
            rex = New System.Text.RegularExpressions.Regex(strInvalid, _
 
System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace)
            If InStr(rex.ToString, strIn) <> 0 Then
                Return True
            End If

        Catch ex As Exception
            UIExceptionHandler.ProcessException(ex)
        End Try

    End Function

Charlotte Foust

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Thursday, September 27, 2007 11:34 AM
To: 'Access Developers discussion and problem solving';
dba-sqlserver at databaseadvisors.com; VBA
Subject: [AccessD] Use Regex - Create Camel Case

Folks,

I am looking for a regex expression (preferably with explanation) for
taking an expression and creating a camel case (or PascalCase)
expression.

I get CSV files with headers in them.  All too often the eejits that
created the databases they came from used embedded spaces or other
special use characters (!@#$%^&* etc) in their field names.  I need to
strip these special characters out completely.  I also need to upper
case the valid alpha character that follows any of these special
characters.




More information about the AccessD mailing list