Regular expressions and HTML5 new elements _ Regular expressions

Source: Internet
Author: User
Tags lowercase modifier regular expression

ProcessOn is an online collaborative graphics platform, providing users with the most powerful and easy-to-use drawing tools!

It can be very easy to draw some things online, let yourself to understand the specific.

Regular expressions

Today's is just learning the simple use of regular. In the face of the HTML5 tag attributes, we can no longer have to learn JavaScript before we go to the regular, because the HTML5 input tag's pattern can be used to verify the label, and to approximate the complex JavaScript using regular validation forms, Will definitely be replaced in the future.

Regular simple use:

[0-9] Find any number from 0 to 9.
[A-z] finds any character that writes from A to lowercase z.
[A-z] looks for any character from uppercase A to uppercase Z.
[A-z] looks for any character from uppercase A to lowercase z.
N{x} matches a string that contains a sequence of X N.
N{x,y} matches a string containing a sequence of X or Y N.
N{x, a string that matches a sequence containing at least X N.

Remember that these few can achieve a simple regular operation. Such as:

<form action= "#" >
<input type= "text" pattern= "[0-9a-za-z]{1,}" required> <input type=
"Submit "Value=" >
</form>

This is a simple validation of form verification with any 0 to 9 or a to Z or a to Z above 1 characters, and required is required to set this text, or it will be prompted to fill in when the form is submitted.

and the specific use of regular, you need to remember the meaning of meta characters, quantifiers and square brackets.

The pattern attribute prescribes a regular match, and only the length of a regular match is written.

It is now not realistic to be like JavaScript RegExp object so convenient, can not go to set modifiers, that is, set the global or case sensitive.

But its function is already very powerful.

And why can't I set a modifier because it's a regular expression, and in the case of the consortium that the pattern is a regular expression, not a string, you have to omit the modifier, so it can't set the modifier, and it's not an error.

Supplementary knowledge: matching Chinese regular

[\u4e00-\u9fa5] This really matches only Chinese

[^\x00-\xff] This matches all non-ASCII characters, that is, half-width characters in the general sense, and these%! (such as full-width characters.)

Audio and video elements of HTML5

Audio Audio Label

<audio controls AutoPlay loop >
<source src= "url" type= "Audio/mp4" >
<source ssrc= "url" type= " Audio/ogg ">
<p> your browser does not support </p> 
</audio>

Effect Chart:

Its properties:

AutoPlay AutoPlay If this property appears, the audio plays immediately after it is ready.

Controls controls if this property appears, the control is displayed to the user, such as the play button.

Loop loop If this property occurs, the playback starts again whenever the audio is finished.

Preload preload If this property occurs, the audio is loaded when the page loads and is ready to play. If "autoplay" is used, the property is ignored.

The URL of the audio to be played by the SRC URL.

Video label

<video controls Loop muted width= "height=" the Display picture url ">
poster= <source" video Local address URL "src=" before playback Video/mp4 ">
<source src=" video Local address URL "type=" Video/ogg ">
<p> your browser does not support </p> 

Its properties:

AutoPlay AutoPlay If this property appears, the video plays immediately after it is ready.

Controls controls if this property appears, the control is displayed to the user, such as the play button.

Loop loop If this property appears, it starts playing again when the media file is finished playing.

Muted muted stipulates that the audio output of the video should be muted.

The poster URL sets the image that is displayed when the video is downloaded, or the image displayed before the user clicks the play button.

Preload preload If this property occurs, the video loads when the page loads and prepares to play. If "autoplay" is used, the property is ignored.

The URL of the video to be played by the SRC URL.

Width pixels Sets the size of the video player.

Height pixels sets the video player's altitude.

They all have three formats, one is MP4, the other is Ogg, and there is a kind of webm, the format that is currently supported in this respect is not perfect.

The above is a small set to introduce the regular expression and HTML5 new elements, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.