练习题3:字符串乱码问题
Open
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 6
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
有乱码的字符串 'I? ?love? the?? ?great ? ? ???wall' 和 'I?love ??the ?great ??wall in ?beijing' 。需要讲字符串还原为正确的句子 "I Love the Great Wall"和 "I Love The Great Wall in Beijing"。
- 乱码字符只有
' '和? - 如果单词前面是
?则该单词首字母大写
解题思路:先找出哪些单词前面有 ? 进行首字母大写处理。再把多余的 '' 和 ? 清除
let str='I? ?love? the?? ?great ? ? ???wall'
str.replace(/\?+([a-z])/g,function($1,$2,$3){return ' '+$2.toUpperCase()}).replace(/[\s\?]+/g,' ')
str='I?love ??the ?great ??wall in ?beijing'
str.replace(/\?+([a-z])/g,function($1,$2,$3){return ' '+$2.toUpperCase()}).replace(/[\s\?]+/g,' ')
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the two malformed string examples and the replacement expressions included in the issue. Check where this exercise belongs in the repository's notes, then verify that the documented result is exactly “I Love the Great Wall” and “I Love The Great Wall in Beijing”.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100