문자열2 [자바스크립트/알고리즘] 특정 문자열로 끝나는지 확인 / 정규식, endsWith() 이용 문제 특정 문자열로 끝나면 true, 아니면 false 반환 나의 풀이 입력: "dogs, cats, and ducks", "ducks" 결과: true function confirmEnding(str, target) { let result = new RegExp(target+"$","i"); return result.test(str); } confirmEnding("dogs, cats, and ducks", "ducks"); 간단하게 endsWith()로 문제를 해결할 수도 있다. [endsWith()] 입력과 결과는 위와 동일하다. 사용방법 function confirmEnding(str, target) { return str.endsWith(target); } (문제 출처:www.freecodeca.. 2021. 1. 18. [C언어] 문자열 행렬 출력 입력 예시) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam 출력 결과) 첫 줄에 행, 열 입력, 두번째 줄에 문장을 입력한 결과이다. 그 후 strtok를 사용하여 띄어쓰기를 기준으로 문장을 나누어 배열에 저장하였다. 배열에 단어로 나누어 저장된 결과 그리고 출력! 간단한 문제였다. #include #include #define MAX 100 int main() { char input[MAX] = { NULL }; char *answer[MAX] = { NULL }; int row .. 2021. 1. 7. 이전 1 다음