[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

01/27/2009 at 06:02AM PST, ID: 24086905
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.4

Conversion of VB program from vb6 to .Net 2008, dealing with Regular Expressions

Asked by rhawk in .NET Framework 3.x versions, Microsoft Visual Basic.Net

Hello and thank you in advance for your help. We are converting a program that started as a classic ASP application, then moved to vb5 then vb6 and now .net 2008.  I am a little confused on the .net RegEx object and converting 3 functions that use Regular Expressions. These functions are called through out the program so are critical. VB6 had an option called "global" which I am unable to locate in .net 2008, and so have not been able to convert the 3 functions. Below are the 3 fuunctions I need to convert. Because they are called all over a large number of forms and modules, I have to keep the function layout the same so the calls work with the new functions. I just do not have the time to hunt down everywhere they are called and adjust the call. Any help you can give is appreciated.

David
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
'-----------------------------------------------------------------
'Function    : reReplace
'Description : Calls a Regular Expression object to do a search/replace on a string
'Parameters  : sString - This is the string to do the search/replace in
'            : sPattern - String containing the regexp pattern for the search
'            : sReplacement - Optional string containing what to replace with. (defaults to blank)
'            : bGlobal - Optional boolean if the search should be global in the string (defaults to false)
'            : bIgnoreCase - Optional boolean if the search should ignore case in the string (defaults to false)
'Result      : Returns the new string
'-----------------------------------------------------------------
Public Function reReplace(sString As String, sPattern As String, Optional sReplacement As String = "", Optional bGlobal As Boolean = False, Optional bIgnoreCase As Boolean = False) As String
    Dim re As New RegExp
    re.Pattern = sPattern
    re.Global = bGlobal
    re.IgnoreCase = bIgnoreCase
    reReplace = re.Replace(sString, sReplacement)
    Set re = Nothing
End Function
 
'-----------------------------------------------------------------
'Function    : reMatch
'Description : Calls a Regular Expression object to see if search exists
'Parameters  : sString - This is the string to do the search/replace in
'            : sPattern - String containing the regexp pattern for the search
'            : bGlobal - Optional boolean if the search should be global in the string (defaults to false)
'            : bIgnoreCase - Optional boolean if the search should ignore case in the string (defaults to false)
'Result      : Returns True/False on if the search was found
'-----------------------------------------------------------------
Public Function reMatch(sString As String, sPattern As String, Optional bGlobal As Boolean = False, Optional bIgnoreCase As Boolean = False) As Boolean
    Dim re As New RegExp
    re.Pattern = sPattern
    re.Global = bGlobal
    re.IgnoreCase = bIgnoreCase
    reMatch = re.Test(sString)
    Set re = Nothing
End Function
 
'-----------------------------------------------------------------
'Function    : reFind
'Description : Calls a Regular Expression object to extract a pattern from a string (1st occurance)
'Parameters  : sString - This is the string to search in
'            : sPattern - String containing the regexp pattern for the search
'            : bIgnoreCase - Optional boolean if the search should ignore case in the string (defaults to false)
'Result      : Returns a string containing the extracted substring
'-----------------------------------------------------------------
Public Function reFind(sString As String, sPattern As String, Optional bIgnoreCase As Boolean = False) As String
    Dim re As New RegExp
    Dim oMC As MatchCollection
    Dim sResult As String
    sResult = ""
    
    re.Pattern = sPattern
    re.Global = False
    re.IgnoreCase = bIgnoreCase
    Set oMC = re.Execute(sString)
    If oMC.Count > 0 Then
        ' remove leading and trailing spaces
        sResult = Trim(oMC.Item(0))
    End If
    Set oMC = Nothing
    Set re = Nothing
    reFind = sResult
End Function
[+][-]01/27/09 08:43 AM, ID: 23478314

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET Framework 3.x versions, Microsoft Visual Basic.Net
Sign Up Now!
Solution Provided By: rhawk
Participating Experts: 0
Solution Grade: A
 
 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625