Javascript Function

Javascript Tutorials, Ajax , Validation, Calculator, DOM

« Drop Down List Validation Thumbnail Image Popups »

MultiLine Mode

All of the regular expressions we have looked at so far will process the text that we are comparing the expression to as if it were a single line. This will work fine provided that we do not need to match patterns against line boundaries.

When we do need to match patterns against line boundaries we need to switch our regular expression into multiline mode. We do this by adding an indicator after the expression the same way we do for ignorecase and global.

var re = /^deal$/mg

With this example the "m" switches the regular expression into multiline mode. This changes the meanings of the "^" and "$" boundary conditions. Now instead of indicating just the start and end of the complete text (so that our example would match only if the complete text was "deal") these boundary conditions in multiline mode represent the start and end respectively of any line. The example expression will therefore match any line within the text that consists just of the word "deal". Of course you don't need to test both start and end of line in your expression in multiline mode, this mode can be used equally well to find lines that just start or end with a particular pattern.

Post comment:

◎welcome to give out your point。

Calendar

Comments

Previous

Powered By http://www.javascriptfunction.com Godaddy Promo Code

Copyright http://www.javascriptfunction.com/. All Rights Reserved.