简体   繁体   中英

Regular Expression: match word at start of sentence

I am wanting to match all occurrences of a certain word (in this case "Jill") that start a sentence in the middle of a paragraph.

"Hello sample string. Jill is great."

Now the expression [.:?!]\\sJill\\b will match this but matches at the position of the full stop. Is it possible to match at the start of the 'J' in "Jill"?

I'm using the c# flavour of regex.

Try this. I haven't tested it yet. (?<=[.:?!]\\s)Jill\\b

您是否考虑过使用分组来捕获Jill?

[.:?!]\s(Jill)\b

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM