Programming Basics #30 Regular Expressions

Опубликовано: 18 Ноябрь 2024
на канале: learn share
1,110
6

http://learn-share.net/programming-ba...
Programming Course. The Basics of Programming.
#30 Regular Expressions

Learn to code.

Introduction to regular expressions

As we know, strings have great built in functionalities, we can convert them to upper case, we can slice peaces out, we can find if a word exists in a string. But what we are more interested in, is in the format itself.

Maybe we want to ask, is it an email address, or is it a url, or perhaps we want to know if a password have a mixture of upper case and lower case letters and special symbols.

Now to do this, many programming languages including java_script, have something called, Regular expressions built in to the language.

Regular expressions are strings looking for sequences of characters, that can describe and can match patterns in strings.

They are not pleasent to begin with, but they very useful and you should know what they are, and what they can do.

You have always two parts to work with regular expressions.
First you create the expression that describes the pattern you looking for.
And second, you try and apply to something, asking if he match's.

So, step one.
We create a variable, i'm calling my, R, E, from my regular expression. Equal to, forward slash, hello, forward slash.

And now you may ask, where is the quotes?
Note that we have the two forward slashes. They marking this as an regular expression.
Is the java_script short hand for doing this.

...