如何使用 ComponentsSeparatedByString: 忽略包含子字符串的单词?
我想使用 -componentsSeparatedByString:
解析以下字符串:
CHAPTER 5. RULE OF DECISION
CHAPTER 6. GOVERNMENTAL EXEMPTION FROM BOND AND SECURITY REQUIREMENTS
CHAPTER 7. LIABILITY OF COURT OFFICERS
SUBCHAPTER A. LIABILITY OF OFFICER
SUBCHAPTER B. LIABILITY OF ATTORNEY
SUBCHAPTER C. SUIT ON OFFICIAL BONDS
CHAPTER 8. STATE EXEMPTION FROM CERTAIN FEES: FEES PAID BY OPPOSING PARTY
CHAPTER 9. FRIVOLOUS PLEADINGS AND CLAIMS
SUBCHAPTER A. GENERAL PROVISIONS
SUBCHAPTER B. SIGNING OF PLEADINGS
CHAPTER 10. SANCTIONS FOR FRIVOLOUS PLEADINGS AND MOTIONS
但是当我使用 CHAPTER
作为分隔符的字符串时,SUBCHAPTER 元素也会被分解,因为它们包含 CHAPTER在他们之内。
使用 -componentsSeparatedByString: 解析 CHAPTER 元素时,如何避免在 SUBCHAPTER 元素上停止?
I would like to parse the following string using -componentsSeparatedByString:
:
CHAPTER 5. RULE OF DECISION
CHAPTER 6. GOVERNMENTAL EXEMPTION FROM BOND AND SECURITY REQUIREMENTS
CHAPTER 7. LIABILITY OF COURT OFFICERS
SUBCHAPTER A. LIABILITY OF OFFICER
SUBCHAPTER B. LIABILITY OF ATTORNEY
SUBCHAPTER C. SUIT ON OFFICIAL BONDS
CHAPTER 8. STATE EXEMPTION FROM CERTAIN FEES: FEES PAID BY OPPOSING PARTY
CHAPTER 9. FRIVOLOUS PLEADINGS AND CLAIMS
SUBCHAPTER A. GENERAL PROVISIONS
SUBCHAPTER B. SIGNING OF PLEADINGS
CHAPTER 10. SANCTIONS FOR FRIVOLOUS PLEADINGS AND MOTIONS
but when I use CHAPTER
as the string to separate by, the SUBCHAPTER elements also get broken up because they contain CHAPTER within them.
How can I avoid stopping on the SUBCHAPTER elements when parsing the CHAPTER ones using -componentsSeparatedByString:?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用正则表达式 regexKit 非常适合此目的。这将帮助您形成您正在寻找的确切模式......
Try using regular expressions regexKit is perfect for this. That will help you to form the exact pattern you are looking for...