VBA RegExp CODE 5019

PauloCastelo

New Member
Joined
Jul 7, 2016
Messages
14
Hi folks,

It's my first time here and I'm needing your help.
I'm trying to use a specific regular expression, but when a I try execute, the message shows "Run-time error 5019"
The regular expression I'm using is "(Sumário\n[^]+)".
I done some tests and the error is "^".
How can I done it?

' Execução da Expressão regular
Dim posString As String
Dim newRegEx, newMatch, newMatches
Set newRegEx = New RegExp
newRegEx.pattern = "(Sumario\n[^]+)"


newRegEx.MultiLine = True
newRegEx.IgnoreCase = True
newRegEx.Global = True

Set newMatches = newRegEx.Execute(strTemp)

For Each newMatch In newMatches
RetStr = newMatch.Value
Next
strTemp = RetStr

My idea is take only expressions after word "Sumario".
I used a Macro to take Word Documment to insert in the string (strTemp)
When I tried used newRegEx.pattern = "(Sumario\n[]+)", it's done, but it's not works.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hello and welcome to The Board.
Does the following give you what you want?
sumario([\w\s]*)
 
Last edited:
Upvote 0
What namely you want to extract? Could you show an example?
 
Upvote 0
Code:
sub M_snb()
  c00="this is an example how to extract text after the word Sumario and nothing else."
  msgbox split(c00,"Sumario")(1)
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top