我需要帮助构建一个正则表达式,以查找前后字符不是a-z和A-Z的所有连字符。以下是应该找到连字符的示例。
以下是一个忽略连字符的示例:
迄今为止,我能够编写以下内容:
非常感谢。
This is - test
this is -test
this is- test
this is 2- test
this is 2 -test
this is 2-2 test
以下是一个忽略连字符的示例:
this is-test
迄今为止,我能够编写以下内容:
(?<=[^a-z])-(?=[^a-z])
这只搜索行中以下划线:
This is - test
this is 2- test
this is 2-2 test
非常感谢。
(?<=[^a-zA-Z])-(?=[^a-zA-Z])
吗?如果连字符是第一个或最后一个字符怎么办?你是指“和”还是“或”? - NetMage