How We Coding

- 여러 공백을 하나의 공백으로 바꾸는 정규표현식

- ref : https://code.i-harness.com/ko-kr/q/1e3ba5



str.replace( / +/g, ' ' )        ->  790ms

str.replace( /  +/g, ' ' )       ->  380ms

str.replace( / {2,}/g, ' ' )     ->  470ms

str.replace( /\s\s+/g, ' ' )     ->  390ms

str.replace( / +(?= )/g, ' ')    -> 3250ms



- 문자열에서 모든 줄 바꿈(개행)을 제거하는 방버

- ref : https://code.i-harness.com/ko-kr/q/a4df85


someText = someText.replace(/(\r\n\t|\n|\r\t)/gm,"");



- 정규표현식을 사용하여 태그만 제거하기

- ref : https://webisfree.com/2015-12-22/[자바스크립트]-정규표현식을-사용하여-태그만-제거하기


var newText = oriText.replace(/(<([^>]+)>)/ig,"");


>> g : 발생할 모든 pattern에 대한 전역 검색

>> i : 대/소문자 구분 안함

>> ref : http://www.codejs.co.kr/자바스크립트에서-replace를-replaceall-처럼-사용하기/



- 특정 태그 추출

- ref: http://maedoop.dothome.co.kr/2231

- ref: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec

'JS > Reference' 카테고리의 다른 글

How to make a Web Crawler in Node.js  (0) 2018.11.24
How JS works  (0) 2018.10.02
이벤트 루프(Event Loop)  (0) 2018.10.02

1. How to make a web crawler in JavaScript / Node.js 

http://www.netinstructions.com/how-to-make-a-simple-web-crawler-in-javascript-and-node-js/



2. “Introduction to Webcrawling (with Javascript and Node.js)” - “Introduction to Webcrawling (with Javascript and Node.js)” @DDCreationStudi

https://medium.com/of-all-things-tech-progress/introduction-to-webcrawling-with-javascript-and-node-js-f5a3798ee8ac

'JS > Reference' 카테고리의 다른 글

[JS] 정규표현식을 이용한 str.replace() / pattern.exec()  (0) 2018.12.26
How JS works  (0) 2018.10.02
이벤트 루프(Event Loop)  (0) 2018.10.02

How JS works

JS/Reference2018. 10. 2. 13:48

1 : https://engineering.huiseoul.com/자바스크립트는-어떻게-작동하는가-엔진-런타임-콜스택-개관-ea47917c8442


2 : https://engineering.huiseoul.com/자바스크립트는-어떻게-작동하는가-v8-엔진의-내부-최적화된-코드를-작성을-위한-다섯-가지-팁-6c6f9832c1d9


3 : https://engineering.huiseoul.com/자바스크립트는-어떻게-작동하는가-메모리-관리-4가지-흔한-메모리-누수-대처법-5b0d217d788d


4 : https://engineering.huiseoul.com/자바스크립트는-어떻게-작동하는가-이벤트-루프와-비동기-프로그래밍의-부상-async-await을-이용한-코딩-팁-다섯-가지-df65ffb4e7e

참고1 : https://meetup.toast.com/posts/89


참고2 : https://vimeo.com/96425312


참고3 : https://stackoverflow.com/questions/10680601/nodejs-event-loop


참고4 : https://johnresig.com/blog/how-javascript-timers-work/


참고 5: https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop


'JS > Reference' 카테고리의 다른 글

[JS] 정규표현식을 이용한 str.replace() / pattern.exec()  (0) 2018.12.26
How to make a Web Crawler in Node.js  (0) 2018.11.24
How JS works  (0) 2018.10.02