Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                /**
 * 正则表达式中的特殊字符
 */
str = '1aaa\n\r2sssss';
result = str.match(/^\d/gm);
console.log(result);//^ ["1", "2"] 如果没有m就返回["1"]
str = 'MY 3 sisters';
result = str.match(/[^a-z\s]/gi);//字符集中出现是取反的
console.log(result);
str = 'aa24accc1a';
result = str.match(/\d+?/g);//一个或一个以上
console.log(result);
str = 'nay, an apple is on the tree';
result = str.match(/.n/g);//匹配任何除了新一行开头字符的任何单个字符
console.log(result);
str = 'foo bar';
result = str.match(/(foo)/g);//捕获
console.log(result);
str = 'abcd.';
result = str.match(/[a-z.]+/g);//字符集
console.log(result);
str = 'moon';
result = str.match(/\bm/g);//匹配一个词的边界
console.log(result);
str = 'apple, orange, cherry, peac';
result = str.match(/appl(e)(,)\sorang\1/g);//返回引用到最后一个与有n插入的正值表达式匹配的副字符串
console.log(result);
str = 'apple, orange, cherry, peac';
result = str.replace(/appl(e)(,)\sorang\1/g, "$1");//替换上面的apple, orange
console.log(result);
//exec方法
var re = /quick\s(brown).+?(jumps)/ig;
var result = re.exec('The Quick Brown Fox Jumps Over The Lazy Dog');
console.log(result);
//test方法
var re = /\d/g;
var result = re.test('1dd55');
console.log(result);
//match方法
var re = /quick\s(brown).+?(jumps)/ig;
var result = 'The Quick Brown Fox Jumps Over The Lazy Dog'.match(re);
console.log(result);
//search方法
var re = /quick\s(brown).+?(jumps)/ig;
var result = 'The Quick Brown Fox Jumps Over The Lazy Dog'.search(re);
console.log(result);
//replace方法
var re = /(\w+)\s(\w+)/;
var str = "John Smith";
var result = str.replace(re, "$2, $1");
console.log(result);
//split方法
var re = /(\d)/;
var result = 'Hello 1 word. Sentence number 2.'.split(re);
console.log(result);
var re = /\d/;
var result = 'Hello 1 word. Sentence number 2.'.split(re);
console.log(result);

//正则表达式执行返回信息
var myRe = new RegExp("d(b+)d", "g");
var myArray = myRe.exec("cdbbdbsbz");
console.log(myArray);

//正则表达式标志
var re = /\w+\s/g;//表达式一
var re = new RegExp("\\w+\\s", "g");//表达式二
var str = "fee fi fo fum";
var myArray = str.match(re);
console.log(myArray);
              
            
!
999px

Console