티스토리 뷰

공부

[JS] RegExp match & test

승가비 2020. 2. 27. 01:11
728x90
var str = "The rain in SPAIN stays mainly in the plain";
var res = str.match(/ain/g);

https://www.w3schools.com/jsref/jsref_match.asp

 

JavaScript String match() Method

JavaScript String match() Method ❮ JavaScript String Reference --> Example Search a string for "ain": var str = "The rain in SPAIN stays mainly in the plain"; var res = str.match(/ain/g); The result of res will be an array with the values: var str = "The

www.w3schools.com

const str = 'table football';
const regex = RegExp('foo*');

console.log(regex.test(str));
// expected output: true

https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test

 

RegExp.prototype.test()

The test() method executes a search for a match between a regular expression and a specified string. Returns true or false.

developer.mozilla.org

https://developer.mozilla.org/ko/docs/Web/JavaScript/Guide/%EC%A0%95%EA%B7%9C%EC%8B%9D

 

정규 표현식

정규 표현식은 문자열에 나타는 특정 문자 조합과 대응시키기 위해 사용되는 패턴입니다. 자바스크립트에서, 정규 표현식 또한 객체입니다.  이 패턴들은 RegExp의 exec 메소드와 test 메소드  ,��

developer.mozilla.org

 

728x90

'공부' 카테고리의 다른 글

[Python] *args  (0) 2020.02.27
Install MongoDB Community Edition on macOS  (0) 2020.02.27
[Java] Date gap  (0) 2020.02.27
[Oracle] Order by DESC nulls last  (0) 2020.02.27
[Oracle] to_date & to_char  (0) 2020.02.21
댓글