Vim regular expression for backslash [duplicate] - regex

This question already has answers here:
How does one escape backslashes and forward slashes in VIM find/search?
(6 answers)
Closed 8 years ago.
I'm inputting LaTeX source into a source file for another language, which means lots of escaping.
I'm having a bit of trouble constructing a regular expression that matches only a single backslash, followed by any number of alphanumerics using Vim regular expressions. My tries, so far, have included:
/[^\\]\\[^\\]+/
including many combinations of escaping. What am I missing?
After a bit more trial and error, it looks like when I do:
/\\[^\\]+
vim is trying to match a backslash followed by any non-backslash followed by a literal +

You need to escape the + quantifier here as well.
/\\[^\\]\+/

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:

How to match all whitespace in VBA [duplicate]

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]+

regexp don't match if contain specific digit length [duplicate]

This question already has answers here:
Regular expression to match a line that doesn't contain a word
(34 answers)
Closed 5 years ago.
I've tried to make a regular expression that match anything except if contains a 11 digits like 12345678910 so don't match anything
what i have tried
[^\d{11}]
but {11} doesn't work with \d expression
so what i have to do ?
you can use the regex
^(?!.*\d{11}).*$
see the regex101 demo
It's not a very good task for regex to solve actually, because you have to describe every string that doesn't contain 11 consecutive digits.
If possible, I suggest matching a string that does contain 11 consecutive digits, then inverting the success of that match with the language or tool from which you execute this regex.
Depending on your regex flavour, you might also be able to use a negative lookahead such as presented in other answers.
This seemed to work for me using a negative look around:
/^((?!\d{11}).)*$/gm

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.