Javascript regular expression help?

(?=.*[a-z]) Is Anybody explain me what is the meaning of " . " and " * " character in this expression. What kind of logic these two character perform here.

Hello there @priyanshushrama709,

in RegEx, the . (dot) means All Characters except for newline. It will match any characters except for line breaks. So that means it will accept,
a - z, !@#$%^&*()_+=-{}[]\|'";:.><,/?~.

The * (star) means 0 or more of the character inforn of it. So it will match 0 or more of it. Here’s an example: /s*/. This regex will match 0 or more s in a string || It will match all the s.

You can play around with RegEx using the https://regexr.com or https://regex101.com. They both are a nice tool, and have references to all the syntaxes.


Hope this helps,
Remember to Stay Safe and Happy Coding!! :)

Catalactics

I want to create a regex for password validation and my problem is that I can’t understand what’s this - (?=.*[a-z]) - expression try to say can you help me I will try myself .

I was try expression on this string: Ultra_123_lord.

So,Here is my output => [ ’ ', index: 0, input: ‘Ultra_123_lord’, groups: undefined ]
Bingo.

Hey, as I already told you, You can try to play around with RegEx using https://regexr.com or https://regex101.com. Anyways, Here’s a pattern of what you were referring. It will actually explain it to you step by step.
https://regexr.com/56me5.


Check it out!!


Hope this helps,
Remember to Stay Safe and Happy Coding!! :)

Catalactics

Hey, can you explain me this line?

That means it will match the everything inside it and then ignore it and match everything INFRONT/AFTER of it. Here’s an example:
/\d(?=px)/.
1pt 2px 3em 4px. The regex will match 2 and 4 because they end with px.


Hope this helps,
Remember to Stay Safe and Happy Coding!! :)

Catalactics

I suggest doing the freeCodeCamp Regular Expressions section in order. For example . is explained in the seventh challenge.

Honestly I don’t know why FCC is so fixated on forward asserts. I did antispam for over a decade, wrote some of the gnarliest regexes around for rules (the porn rules were always fun to read), and I can count on one hand the number that used forward asserts. Usually I just used two regexes and required both to match.

Backward asserts are more limited, but seen in the wild far more often. They’re also easier to use because they’re always anchored at the end of a positive match.