开发者

Regular expression lowercase

开发者 https://www.devze.com 2023-03-30 06:33 出处:网络
I\'m using this regex to lowercase prepositions, conjunctions, etc. in text files, and I want to add 2 exceptions: do not lowercase when $1 is preceded by \":\" or preceded by \"-\". What is 开发者_如

I'm using this regex to lowercase prepositions, conjunctions, etc. in text files, and I want to add 2 exceptions: do not lowercase when $1 is preceded by ":" or preceded by "-". What is 开发者_如何学Gothe proper, concise way to do that. Thanks.

s/(\s(?:a|about|an|and|at|by|for|from|in|is|it|of|on|the|to|with))\b/\L$1/gi;


Add a negated look-behind before $1:

(?<![:-])
0

精彩评论

暂无评论...
验证码 换一张
取 消