Help needed with RegExp Replace

p13rameshk

New Member
Joined
Jan 27, 2017
Messages
3
hi all,

I am facing trouble constructing a regexp replace function.

For example,
current string: "I need help", he replied.
characters to be replaced: "I need help", (including the quotations and the comma)
final string expected: he replied.

Th regexp I am trying to use is ".+",

My code looks like:

Sub RegEx_Tester()
Set RegExp = CreateObject("vbscript.regexp")
RegExp.Global = True
RegExp.IgnoreCase = False
RegExp.Pattern = "".+","

I am getting the Expected: end of statement error.

Please help me resolve this. I have enabled RedExp in tools--> References

Thanks,
RK
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi,

just a guess (without test)

.Pattern = """.+"","

New = oldStr.Replace("")

Maybe later I will boot the pc

regards
 
Upvote 0
Hi,

now it is tested

Code:
Sub Fen()
Tx = Cells(1, 1) 'content: qwe "A Text", gfd
With CreateObject("vbscript.Regexp")
.Pattern = """.+"","
T = .test(Tx)
Tn = .Replace(Tx, "")
Debug.Print T, Tn
End With
End Sub
8Sub Fen()
Tx = Cells(1, 1) 'content: qwe "A Text", gfd
With CreateObject("vbscript.Regexp")
.Pattern = """.+"","
T = .test(Tx)
Tn = .Replace(Tx, "")
Debug.Print T, Tn
End With
End Sub


regards
 
Upvote 0

Forum statistics

Threads
1,215,912
Messages
6,127,685
Members
449,398
Latest member
m_a_advisoryforall

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