?
Solved

Regular Expression support in visual basic

Posted on 2003-03-28
9
Medium Priority
?
268 Views
Last Modified: 2013-11-25
I am in need of reference material on using regular expressions in visual basic - not vbscript but visual basic. I need to replace the occurences of the following characters inside a string '. : ; / | ? *'. I have tried microsoft but their site has just to many levels...

0
Comment
Question by:roustnissen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 8224570
0
 

Author Comment

by:roustnissen
ID: 8224670
... well not quite!
what I need is reference material so that can write my own expressions in visual basic 6.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 8224692
You want to parse yourself string finding patterns in it and replacing them?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:roustnissen
ID: 8224717
Yes, I am having a string that might contain one or more of the above and I need to replace that char with a '.'.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 8224771
So it doesn't need to be regular expressions:

x = replace(x,".", ".")
x = replace(x,":", ".")
x = replace(x,";", ".")
...
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 400 total points
ID: 8224796
Try this:

Private Sub Command1_Click()
    MsgBox ReplaceChars("this is ; / a tes;t string?*", ".:;/|?*", ".")
End Sub

Private Function ReplaceChars(ByVal pstrX As String, ByVal pstrFind As String, ByVal pstrReplace As String) As String
Dim intI As Integer
    For intI = 1 To Len(pstrFind)
        pstrX = Replace(pstrX, Mid$(pstrFind, intI, 1), pstrReplace)
    Next intI
    ReplaceChars = pstrX
End Function
0
 
LVL 3

Assisted Solution

by:emadat
emadat earned 400 total points
ID: 8225149
Hi..
emoreau's solution is an elegant one.

However; if you still insist on using regular expressions;  you can use a Windows Script object to so that.
Here is an article from Microsoft on how to use it -including an example-:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnclinic/html/scripting051099.asp

Download Windows Script 5.6 for Windows 2000 from: http://www.microsoft.com/downloads/details.aspx?FamilyId=C717D943-7E4B-4622-86EB-95A22B832CAA&displaylang=en

Download Windows Script 5.6 Documentation from: http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en


Also here are some links to tutorials:

http://www.devarticles.com/art/1/302/1
http://www.aivosto.com/vbtips/regex.html
http://nltk.sourceforge.net/tutorial/regexps/nochunks.html
http://www.evolt.org/article/rating/20/22700/
0
 

Expert Comment

by:CleanupPing
ID: 8531413
Hi roustnissen,
This old question (QID 20566347) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9440824
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->Split between emoreau and emadat

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question