How to match all whitespace in VBA [duplicate] - regex

This question already has answers here:
How do I isolate a space using RegExp in VBA (\s vs. \p{Zs})?
(3 answers)
Closed 4 years ago.
I am having a similar issue as this question here. \s is not matching all white spaces in VBA.
But I want to catch all kinds of whitespace - spaces, tabs, newlines, thin space, hair space etc. and not only one of them.
Is there another possibility than hard coding every unicode value like the following?
With regEx
.Global = True
.Pattern = "(\s|\u2009|\u2008|.............)"
End With
How do I isolate a space using RegExp in VBA (\s vs. \p{Zs})? wants to isolate spaces - I want readable and reliable way to match any whitespace without needing to list the unicode values for them as proposed by the one who closed the question.

There is no perfect alternative, therefore I suggest to use exact values/codes.
You should be safe with this regex pattern:
[\s\n\r\t \xA0\u1680\u180E\u2000-\u200B\u202F\u205F\u3000\uFEFF]+

Related

RegEx for special characters and decimals except for commas [duplicate]

This question already has an answer here:
Learning Regular Expressions [closed]
(1 answer)
Closed 3 years ago.
Regex testing for special characters, decimal except for hyphen, commas, alpha-numeric.
Attempt
^(\+|-)?([0-9]+)$/
I'm trying to write a regex to match special characters, decimal except for commas, a hyphen, alpha-numeric.
Welcome!
Maybe, you might just want to list the chars that you wish in a [] and test it. Maybe, a simple expression like this would be desired for you and you could work on it:
^([?!"'~&%$*##0-^#9]+)$
You might want to use this tool and design an expression that you wish, then test it with real samples and maybe change it as you wish.
You can also use an online visualizer to view how your expression would work:

Why using (.|\n)*? is a bad idea? [duplicate]

This question already has answers here:
How do I match any character across multiple lines in a regular expression?
(26 answers)
Regex search with pattern containing (?:.|\s)*? takes increasingly long time
(1 answer)
Closed 3 years ago.
A few times I saw regex experts say that using (.|\n)*? is a really, really bad idea.
Well, I do understand that it's better to replace it with the .* and use the /s flag. But sometimes the flags are not available, for example, when using regex within a text editor or other software with limited regex functionality. Thus, using something like (.|\n)*? might be the only option for multi-line matching.
So, what are the reasons to always avoid (.|\n)*??

Finding a group match part of another group in a regex [duplicate]

This question already has answers here:
How to use regex to find all overlapping matches
(5 answers)
Closed 5 years ago.
I was just wondering how to match a group which has characters already in another group.
If we take this string for example: "aba" and want to match every group of (ab) or (ba).
Obviously (ab|ba) would work, my only problem with that is it only catches one group which is aba but i also want to capture aba, do I have to use a more complex regex for this case?
You can easily achieve this using this regex
(?=(ab|ba))
It will match all the occurrences of both 'ba' and 'ab' even the overlap ones.

what does "\S" equal in Regex? [duplicate]

This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 8 years ago.
What does "\S" equal in Regex?
I have a regex:
/<((?:https?\:\/\/)*(?:[^\/?#])\/*\S*)>/ig;
trying to match:
What does \S equal? e.g.: [\w\d?:"-_]
\S matches anything except whitespace.
Regard as the opposite of \s (which matches whitespace).
(Personally I find \S obfuscating for this reason, particularly when viewing in some fonts where S and s look too similar. I prefer [^\s]).
\S means "Non-whitespace characters".
See Wikipedia

Match all Strings without the word "authorize" in them [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Java \ Pattern - how to write a pattern that verifies the lack of a string?
How can I match all strings without the word "authorize" in them via regular expressions? I tried *(authorize){0}* to no avail.
/^(?!.*authorize).*/
This uses a negative lookahead to ensure that the overall pattern will match only if the expression "authorize" cannot match anywhere in the input.