-
Notifications
You must be signed in to change notification settings - Fork 66
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
Conversation
🦋 Changeset detectedLatest commit: f8ef0b9 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
src/parseHangul.ts
Outdated
* parseHangul('가나다!-29~라마바.,,사') // '가나다라마바사' | ||
*/ | ||
|
||
export function parseHangul(str: string): string { |
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.
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을 사용할 것인지 말것인지에 대한 의견이 필요해요
이 함수 명칭은 removeUnHangul 같은 지운다는 뜻을 포함했으면 좋겠습니다. 정규식에서 + 는 큰 단위의 반복을 줄여 성능을 높이는 효과가 있습니다. ps. 저 식대로면 ㅠㅠ 같은 문자도 지워지는데 함수의 역할이 무엇인가요? |
이 부분에 동의하여, 한글을 지운다는 맥락을 설명할 수 있는 함수명, 혹은 주석에 "한글을 추출" 한다고 작성해주신것을 따라 |
이 부분은 현재 구현대로 띄어쓰기는 삭제하지 않는 것이 좋을 것 같아요~ 라이브러리를 사용하는쪽에서 정말 띄어쓰기를 삭제하고 싶으면 사용하는 쪽에서 제어할 것 이라고 생각해요 |
@crucifyer 피드백 해주셔서 감사합니다 ! |
테스트 코드 보완과 함께 수정 완료 했습니다 ! |
src/extractHangul.spec.ts
Outdated
@@ -0,0 +1,51 @@ | |||
import { extractHangul } from './extractHangul'; | |||
|
|||
describe('extractHangul 함수 테스트', () => { |
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.
일관성을 유지하기 위해서 , 함수 테스트 글자를 지우는것은 어떨까요?
describe('extractHangul 함수 테스트', () => { | |
describe('extractHangul', () => { |
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.
넵 !
src/extractHangul.spec.ts
Outdated
it('숫자와 알파벳 추출', () => { | ||
expect(extractHangul('안녕하세요1234abc!@#')).toBe('안녕하세요'); | ||
}); | ||
|
||
it('한글이 없는 문자열', () => { | ||
expect(extractHangul('1234abc')).toBe(''); | ||
}); | ||
|
||
it('한글과 공백만 남기고 다른 문자는 추출', () => { | ||
expect(extractHangul('한글과 영어가 섞인 문장입니다. Hello!')).toBe('한글과 영어가 섞인 문장입니다 '); | ||
}); | ||
|
||
it('특수문자 추출', () => { | ||
expect(extractHangul('특수문자!@#가 들어간 경우')).toBe('특수문자가 들어간 경우'); | ||
}); | ||
|
||
it('숫자와 특수문자 추출', () => { | ||
expect(extractHangul('숫자1234와 특수문자!@# 추출')).toBe('숫자와 특수문자 추출'); | ||
}); | ||
|
||
it('공백 유지', () => { | ||
expect(extractHangul('공백도 유지됩니다 이렇게')).toBe('공백도 유지됩니다 이렇게'); | ||
}); | ||
|
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.
추후 다른 PR에서 작업되도 좋겠습니다,
현재 it구문이 너무 병렬적으로 나와있으니 인지적으로 힘든 것 같아요.
비슷한 맥락인 것들은 describe 메서드를 사용해 한번 grouping해주면 좋을 것 같아요
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.
넵 추가적인 PR 만들겠습니다 !
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.
extractHangul에 대한 문서 작업도 진행해주시면 감사하겠습니다.
API가 실제로 추가되는것이기때문에 문서에서도 표현되었으면 좋겠어요!
src/extractHangul.spec.ts
Outdated
import { extractHangul } from './extractHangul'; | ||
|
||
describe('extractHangul', () => { | ||
it('숫자와 알파벳 추출', () => { |
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.
숫자
it('숫자와 알파벳 추출', () => { | |
it('숫자와 알파벳과 특수문자를 제외한 한글 추출', () => { |
src/extractHangul.spec.ts
Outdated
|
||
it('한글과 공백만 남기고 다른 문자는 추출', () => { | ||
expect(extractHangul('한글과 영어가 섞인 문장입니다. Hello!')).toBe('한글과 영어가 섞인 문장입니다 '); | ||
}); | ||
|
||
it('특수문자 추출', () => { | ||
expect(extractHangul('특수문자!@#가 들어간 경우')).toBe('특수문자가 들어간 경우'); | ||
}); | ||
|
||
it('숫자와 특수문자 추출', () => { | ||
expect(extractHangul('숫자1234와 특수문자!@# 추출')).toBe('숫자와 특수문자 추출'); | ||
}); |
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.
한글을 추출하여, return값으로 주는것이기때문에
한글을 추출
하고, 다른건 제외
한다는 표현을 사용하면 좋을 것 같아요
@okinawaa |
* extractHangul('가나다!-29~라마바.,,사') // '가나다라마바사' | ||
*/ | ||
|
||
export function extractHangul(str: string): string { |
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.
실제 사용할 수 있도록 src/index.ts에서 export 해주시면 좋을 것 같아요
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.
완료했습니다 ! 감사합니다 !
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.
긴 작업 감사합니다!
* feat: parseHangul * fix: parseHangul의 이름을 extractHangul로 수정 및 테스트 코드 보완 * test: 일관된 테스트 코드 작성이 될 수 있도록 describe 설명 수정 * test: 테스트 코드 수정 * docs: extractHangul의 문서 작성 * test: 테스트 문구 수정 * fix: index.ts에 export 추가 * Create fresh-students-sit.md --------- Co-authored-by: 박찬혁 <[email protected]>
Overview
문자열에서 한글만 반환하는
extractHangul
을 구현합니다. #108고민점
\s
정규표현식을 통해\n
과 같은escape
문자열은 한글로 인식되어 처리하고 있습니다.escape
문자열도 필터링할 지에 대해 고민 후, 한글과 혼용되어 사용될 것이라 생각하고 필터링하지 않았습니다.PR Checklist