regex - Is there a way to get the beginning of a word based on the match of the end of the word?
问题描述
I'm trying to create a regex that can find all words that end with "Ctrl" and get only the beginning of the word. So for "QuestionCtrl" I would only want to get "Question".
So far I've boiled it down to something like this: \b(\w*(Ctrl)\w*)\b
解决方案
听起来你正在寻找前瞻:
\b\w+(?=Ctrl\b)
推荐阅读
- python - 如何使用 Graph API 或 Python SDK 在同一个 Facebook 帖子中添加多张照片和/或视频
- javascript - 以角度添加动态搜索输入元素
- intellij-idea - JDK15 上的 JAXB:需要哪些 jar?
- video - 使用 FFMpeg 水印
- c - 使用函数检查相等的矩阵
- rstudio - 将所有内容保存在 Rproj 中的最佳方法是什么,以便您可以在重新打开时继续离开的地方?
- python - 计算由另一列值分组的列值在 pandas 数据框中的共现
- nestjs - 如何在拦截器中使用 TypeORM 保存到数据库
- javascript - 每次注册新的“学生”实体时,如何使用 Sendgrid 和 Strapi 发送确认电子邮件?
- arm - 带有 N 位加法器的 LEGv8 扩展