Regex for uppercase lowercase and some special characters [duplicate] - regex

This question already has answers here:
Regular expression to check if password is "8 characters including 1 uppercase letter, 1 special character, alphanumeric characters"
(14 answers)
Closed 8 years ago.
I want an regex for password which contain following:
It must contain one uppercase letter.
It must contain one lowercase letter.
It also may include symbols but not these:=?<>()'"/\&.
Legth is minimum 8 and maximum 20
Help me please......
Some valid inputs : Abscedsd Ancbdj123 asjkQs23
Some invalid are : asdfghjk Asdfghj& ashhgWhd=?

Try this:
^.*(?=.{8,20})(?=.*[a-z])(?=.*[A-Z])(?=.*[-_]).*$
or just look around in the forum

Have you tried this? - ^(?=.\d)(?=.[a-zA-Z]).{4,8}$
I also found this within this site: ^(?=.[a-z])(?=.[A-Z])(?=.\d)(?=.[$|~=[]'+#.-])[a-zA-Z0-9$|~=[]'+#.-]{8,}$
The entire link is here: Regular expression for password with certain special characters excluding all others

You can use this regex:
^(?=.*?[A-Z])(?=.*?[a-z])(?!.*?[=?<>()'"\/\&]).{8,20}$
Working Online Demo: http://regex101.com/r/lY9iU0
But it will be better in future if you show your own attempts to solve the problem.

Related

Regular Expression - select string between 2 expressions [duplicate]

This question already has answers here:
Regex Match all characters between two strings
(16 answers)
RegEx match open tags except XHTML self-contained tags
(35 answers)
Closed 2 years ago.
I would like to mark all strings between 2 strings with the regular expression.
Example:
https://regex101.com/r/Etfpol/1
I want regular expression to mark follow text:
Solution changed from
Resolved Time changed
Updated By changed from
enter image description here
Thanks
You can use positive lookbehind and positive lookahead to check the tags.
(?<=<Name>Description<\/Name><Value>).*?(?=<\/Value>)
Match results
Solution changed from
Resolved Time changed
Updated By changed from
If you prefer not to use them, this will work as well, but the full match will include the strings before and after your desired string.
(?:<Name>Description<\/Name><Value>)(.*?)(?:<\/Value>)

REGEX - How can I return text between two strings [duplicate]

This question already has answers here:
Regular expression to get a string between two strings in Javascript
(13 answers)
Closed 3 years ago.
Link Regex101
I am using (FD.*?)FD however I am missing every second expression - see regex. Any ideas?
The trailing "FD" in your regex matches the "FD" in the input that starts the next "item" in the input text, so the entire next "item" is skipped, until it finds another "FD".
In a case like this, instead of specify .* followed by the pattern that starts the next item, you typically want to specify anything not including a pattern of FD.

Regex to match an exact number of characters in a string [duplicate]

This question already has answers here:
regular expression to match exactly 5 digits
(5 answers)
Closed 4 years ago.
I'm trying to get a match of 9-digit integer number. The text I'm scanning can be a length of 1-200 character.
The trouble I'm running in to is that I do not want to match if the input has a series of digits longer than 9. I also need to match if the whole input string is 9 digits. Or begins or ends with the 9-digit number.
I've tried:
d{9} > This matches sub-strings longer than 9 digits
d{9}(\D) > This works unless the sub-string is at the end since this expects some character after the 9 digits.
I have search a lot but I have not found this exact issue. Any ideas?
Note: I happen to be working with ColdFusion for this particular issue but I'm hoping that a general regex will do the trick. If necessary I can code this in CFML.
Use alternatives to match a non-digit or beginning/end of the string:
(^|\D)\d{9}($|\D)

Regex pattern for String not ending in a sequence [duplicate]

This question already has answers here:
Regex: match everything but a specific pattern
(6 answers)
Closed 4 years ago.
I am trying to find all strings not ending with the sequence -6X.
What i'm trying to do is compare the value of an xml tag with a sequence.
If it matches then do some stuff.
However I am unable to do so. I want to achieve this without any lookaheads or lookbehinds.
I've tried using .*[^-6X]
However this does not work for strings ending in - or -5 .
I want to ignore strings ending in -6X only and every other pattern should work.
Thanks in advance for your help
This matches Strings NOT ending with -6X:
.*?([^-]..|.[^6].|..[^X])$
https://regex101.com/r/omwkQ3/2

Regex to match exact number [duplicate]

This question already has answers here:
Regex match exact number not if it exist in string
(2 answers)
Closed 2 years ago.
I have a lot of LOC of a project in visual studio and I want to search for every line which uses the numbers 12 and 13. It can't be part of a bigger number, I need to retrieve only the code that actually uses the constants 12 and 13. I think it is possible to do with regex but I'm having a hard time here.
Any help will be very appreciated.
Brief
You want to use the Find and Replace window found at Edit -> Find and Replace -> Find in Files with the regex \b1[23]\b and the Find Options Use Regular Expressions checkbox selected.
Code
\b Word boundary assertion
Matches, without consuming any characters, immediately between a character matched by \w and a character not matched by \w (in either order). It cannot be used to separate non-words from words.
1 Match this literally
[23] Match a character in the set (2 or 3)
\b Word boundary assertion
(?<![0-9])1[23](?![0-9])
Will match
12
13
abc12hbd
but not
3456324123656
234564567546
121212
13121312
1
3
123
If your 12 or 13 might appear in a hexadecimal string you can exclude that with
(?<![0-9a-fA-F])1[23](?![0-9a-fA-F])
You need to decide what characters are allowed to be on either side of the 12 or 13 and then exclude the others. See https://regex101.com/ for more help
This might be a solution:
^\D*(?<p>12|13)\D*
the group with the name p would hold the 12 or 13.
But you better try to use an online regex tester such as https://regex101.com/ or any other that shows up on google.