Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Regular Expression pattern for word search

Posted on 2008-10-16
6
Medium Priority
?
1,301 Views
Last Modified: 2012-06-22
I am using VBA in MS Access 2003 referencing "Microsoft VBScript Regular Expressions 5.5"
I want a collection of all the complete words in my search string that contains the pattern "colla".
So what must the Regular Expression search pattern be to return all the words in this string:
strMySeachString = "collaborate collaboratively collastart thecollatest incollalong endincolla COLLAnow"
0
Comment
Question by:vergenoeg
[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
  • 4
6 Comments
 
LVL 5

Accepted Solution

by:
zmo earned 1000 total points
ID: 22737251
> strMySeachString = "collaborate collaboratively collastart thecollatest incollalong endincolla COLLAnow"

I don't know any VB, but I do know about regexps.
from what I see, you have the 'colla' substring in all of these strings, so a regexp could be :

[a-zA-Z]*[cC][oO][lL][lL][aA][a-zA-Z]*

([a-zA-Z] can also be \w, depending on your regexp language])
0
 

Author Comment

by:vergenoeg
ID: 22737319
It works great.  Thanks.  What if there are digits in the string as well, like:
strMySeachString = "colla2222 222collastart the222collatest COLLA12345"
0
 

Author Comment

by:vergenoeg
ID: 22737434
So I want all these words to be returned when "colla" is supplied:
strMySeachString = "collaborate collaboratively collastart thecollatest incollalong endincolla COLLAnow colla2222 222collastart the222collatest COLLA12345 "
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

Author Comment

by:vergenoeg
ID: 22737518
I see your initial solution works for this as well.  Many thanks.
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 22737532
as zmo noted, use of \w is an option but would match [a-zA-Z0-9_], if the [_] is an issue replace \w below with [a-z0-9]

Set regEx = New RegExp
regEx.Global = True
regEx.IgnoreCase = True
regEx.Pattern = "\w*colla\w*"
Set Matches = regEx.Execute(strMySeachString)
0
 

Author Closing Comment

by:vergenoeg
ID: 31507011
Thanks for your help.  This was my first ever question here, so I hope I did everything right!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

715 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