Member Avatar
[NOPE]FOREVER
  1. Exactly what are regex?
  2. Do we write them ourselves or are they prdefined expressions?
  3. If we can write regex ourselves, how do we write them?
  4. How do they check for invadalities?

For example the email regex:

[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+\.[a-zA-Z]{2,4}

how does this expression check for valid email addresses?

I have tried to look for simple explanations on the web but have found nothing confusing stuff.

Thankyou!

Exactly what are regex?

Patterns for testing against input strings.

Do we write them ourselves or are they prdefined expressions?

You write them, but there are many examples readily available.

If we can write regex ourselves, how do we write them?

Text editor or tool.

how does this expression check for valid email addresses?

Besides the fact that it's flawed:

[-0-9a-zA-Z.+_]+

1 or more characters within the []

\.

A dot.

[a-zA-Z]{2,4}

2, 3 or 4 characters within the [].

I have tried to look for simple explanations on the web but have found nothing confusing stuff.

http://www.regular-expressions.info