473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Find All Instances of a Subpattern Using RegExp?

Using the Microsoft VBScript Regular Expressions 5.5 library in
MS-Access VBA 6.3.

I understand why the code below finds an occurance of the string "PC:
blah blah blah A: BBB aaa B: BBB bbb C: BBB ccc"" but I cannot think
how to make it find all such strings.

My two alternative kludges are;
- build up a pattern of subpatterns until the pattern will not match
- add some hard delimiter (unusual single character) and divide the
incoming document into sections first

Any help would be great.

Function bigregexp()
' Search all the words in a string
Dim re As New regexp, m As Match
Dim t As String, i As Integer
t = "jfk jfk jfk AAA PC:AAA junk A: AAA aaa B: AAA bbb C: AAA ccc
BBB " & _
"PC: BBB junk A: BBB aaa B: BBB bbb C: BBB ccc"
re.Pattern = "(PC:.*A:(.+)B:(.+)C:(.+))"
re.Global = True
For Each m In re.Execute(t)
For i = 0 To m.SubMatches.Count - 1
MsgBox ("Pattern: " & m.SubMatches(i))
Next i
Next
End Function

May 10 '06 #1
1 2584
Replacing the multi-character delimiter "PC:" with a single character
"#" seems to work like so;

Sub bigregexp()
' Search all the words in a string
Dim re As New RegExp, m As Match
Dim t As String, inpos As Integer
t = "jfk jfk jfk AAA PC:AAA junk A: AAA aaa B: AAA bbb C: AAA ccc
BBB " & _
"PC: BBB junk A: BBB aaa B: BBB bbb C: BBB ccc"
t = Replace(t, "PC:", "#", , , vbTextCompare)
re.Pattern = "#[^#]*A:([^#]+)B:([^#]+)C:([^#]+)"
re.Global = True
For Each m In re.Execute(t)
For i = 0 To m.SubMatches.Count - 1
MsgBox ("Pattern: " & m.SubMatches(i))
Next i
Next
End Sub

I wonder if there is another solution?

May 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Han | last post by:
Using preg_match_all, I need to capture a list of first and last names plus an optional country code proceeding them. For example: <tr><td>AU</td><td>Jane Smith</td></tr>...
4
by: David | last post by:
Hi, I've had a search through google but couldn't really find the answer I was looking for.I'm new to PHP, so please take it <relatively> easy. I've created a script which runs some SNMP...
3
by: hokiegal99 | last post by:
How do I say: x = string.find(files, 'this', 'that', 'the-other') currently I have to write it like this to make it work: x = string.find(files, 'this') y = string.find(files, 'that') z =...
3
by: trialofmiles | last post by:
Is there any reason why RegExp wouldn't be able to find a period? str = '256.89'; a = new RegExp('(\.)'); b = /(\.)/; alert(str.replace(a, 'x$1x')); alert(str.replace(b, 'x$1x')); The alert...
11
by: Laiverd.COM | last post by:
Hi, In the following function I keep getting a 'Object expected at line 75 char 5' but for the life of me I cannot find the error. Maybe someone would be so kin to have a look? I indicated the...
5
by: Illya Havsiyevych | last post by:
Hello Anybody knows regexp used in CodeModule Find Method I'm trying to use regexp's to find all procedures in CodeModule Maybe there is other way in Access Thank You Illya
12
by: Vinicius | last post by:
Hi people, How can I find a IP adress in a string using regexp? Received: from unknown (HELO u7b3u5) (naxata@200.228.69.237 with login) Thanks to all.
1
by: Karen | last post by:
I am very new to MySQL- I currently have an VBA module using a VBSCript that will find different aspects of a text string that are a unique text string and turn it into a not so unique text string....
13
by: Kun | last post by:
I have a python-cgi file that pulls data from an sql database, i am wondering what is the easiest way to remove all instances of '00:00:00.00' in my date column. how would i write a python...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
0
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...
0
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...
1
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)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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....
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.