[英]How do I match the first character in string, AFTER a certain character?
I want to match the first character AFTER a hyphen. 我想在连字符后匹配第一个字符。 See below. 见下文。
Language: PHP or JavaScript. 语言:PHP或JavaScript。
example: 例:
my-first-name 我的名字
I want to match the characters 我想匹配字符
f and n f和n
thanks! 谢谢!
Positive lookbehind is the way to go, but you probably want 前进的方向是积极的方向,但您可能想要
(?<=-).
or 要么
(?<=-)[^-]
(if you want to avoid capturing '-' in strings----like--this). (如果您要避免在字符串中捕获“-”(例如this))。
试试这个:
-(.)
Not clear if by 'match' you mean 'capture' the first character after the dash. 不清楚“匹配”是指“捕获”破折号后的第一个字符。
This will match the pattern: 这将匹配模式:
m/-[a-zA-Z]/
This will capture: 这将捕获:
m/-([a-zA-Z])/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.