-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 문자열에서 한글만 반환하는 extractHangul을 구현합니다. #130
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5e81807
feat: parseHangul
Collection50 fca8a59
fix: parseHangul의 이름을 extractHangul로 수정 및 테스트 코드 보완
Collection50 c49d256
test: 일관된 테스트 코드 작성이 될 수 있도록 describe 설명 수정
Collection50 ee9b012
test: 테스트 코드 수정
Collection50 ce8e175
docs: extractHangul의 문서 작성
Collection50 3bf4fba
test: 테스트 문구 수정
Collection50 f7b29f2
fix: index.ts에 export 추가
Collection50 1d3df38
Merge branch 'main' into feat/parseHangul
Collection50 f8ef0b9
Create fresh-students-sit.md
okinawaa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { parseHangul } from './parseHangul'; | ||
|
||
describe('parseHangul 함수 테스트', () => { | ||
test('숫자와 알파벳 제거', () => { | ||
expect(parseHangul('안녕하세요1234abc!@#')).toBe('안녕하세요'); | ||
}); | ||
|
||
test('한글이 없는 문자열', () => { | ||
expect(parseHangul('1234abc')).toBe(''); | ||
}); | ||
|
||
test('한글과 공백만 남기고 다른 문자는 제거', () => { | ||
expect(parseHangul('한글과 영어가 섞인 문장입니다. Hello!')).toBe('한글과 영어가 섞인 문장입니다 '); | ||
}); | ||
|
||
test('특수문자 제거', () => { | ||
expect(parseHangul('특수문자!@#가 들어간 경우')).toBe('특수문자가 들어간 경우'); | ||
}); | ||
|
||
test('숫자와 특수문자 제거', () => { | ||
expect(parseHangul('숫자1234와 특수문자!@# 제거')).toBe('숫자와 특수문자 제거'); | ||
}); | ||
|
||
test('공백 유지', () => { | ||
expect(parseHangul('공백도 유지됩니다 이렇게')).toBe('공백도 유지됩니다 이렇게'); | ||
}); | ||
|
||
test('모든 영어, 숫자, 특수문자를 제거', () => { | ||
expect(parseHangul('모든 영어와 숫자, 특수문자1234abc!@# 제거')).toBe('모든 영어와 숫자 특수문자 제거'); | ||
}); | ||
|
||
test('한글과 공백만 남기기', () => { | ||
expect(parseHangul('한글만 남습니다. 가나다라1234 마바사!@#')).toBe('한글만 남습니다 가나다라 마바사'); | ||
}); | ||
|
||
test('줄바꿈을 유지', () => { | ||
expect(parseHangul('한글과\n줄바꿈')).toBe('한글과\n줄바꿈'); | ||
}); | ||
|
||
test('탭과 공백을 유지', () => { | ||
expect(parseHangul('Tab\t과 공백')).toBe('\t과 공백'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @name parseHangul | ||
* @description | ||
* 문자열을 입력받고 한글만 추출해 반환합니다. | ||
* | ||
* @param {string} chars 모든 문자열 | ||
* | ||
* @example | ||
* parseHangul('안녕하세요1234abc') // '안녕하세요' | ||
* parseHangul('abcde') // '' | ||
* parseHangul('안녕하세요ㄱㄴ') // '안녕하세요ㄱㄴ' | ||
* parseHangul('안녕하세요 만나서 반갑습니다') // '안녕하세요 만나서 반갑습니다' | ||
* parseHangul('가나다!-29~라마바.,,사') // '가나다라마바사' | ||
*/ | ||
|
||
export function parseHangul(str: string): string { | ||
return str.replace(/[^ㄱ-ㅎ가-힣\s]/g, ''); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@okinawaa #121 이름짓기 이슈가 해결되고 승인되면 좋겠습니다
@Collection50 같이 이슈 봐주시면 좋겠어요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manudeli #121 이슈에 의견이 필요하다는 말씀일까요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네 맞아요 ~Hangul을 사용할 것인지 말것인지에 대한 의견이 필요해요