Click here to Skip to main content
16,022,061 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've been using the same Regex pattern since VS 2017 for a spell checker. But one of several issues with VS 2022 is that the same pattern generates errors in my VB code. The pattern is:

Dim ptrn as string = "\b[a-zA-Z0-9]{1,}['’-]{0,}[a-zA-Z0-9]{0,}\b|b\w+[\.\,\?\!]\w+\b"


The purpose of the pattern is to detect each word in a text doc including hyphenated words and English contractions. Error messages include "b is not declared" and "missing braces."

I am assuming this is something to do with a setting is VS 2022 I don't know about. Any info is greatly appreciated.

What I have tried:

Tried breaking up the string and replacing the apostrophes with chrw(27).
Posted
Comments
CPallini 5-Sep-24 3:36am    
You could mark it as 'solved' or even delete it.

1 solution

OK never mind I found it. It was a misplaced quote in a line of code above this one. No error msg, no red line, nothing.
 
Share this answer
 
Comments
Richard Deeming 9-Sep-24 4:47am    
VB.NET has supported multi-line strings since VS2015. As a result, if you don't close a string on a previous line, it's not an error; the string just keeps going until the next quote character. The errors will then appear with the contents of that string, when the compiler tries to interpret them as code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900