I was trying to match (using regex) string which can contains anything but it must start with uppercase letter, for example:
我试图匹配(使用regex)字符串,该字符串可以包含任何内容,但必须以大写字母开头,例如:
"Harkon's Sword"
I wrote something like this:
我写的是这样的:
^[A-Z][A-Za-z0-9,;'\"\\s]*\s
which finds "Harkon's "
but not the other word. Can you help with this?
它找到了“Harkon’s”而不是“Harkon”。你能帮忙吗?
Other examples of strings I want to find:
我想找的其他字符串的例子:
"Dragonbane",
"Skaal Armor",
"Horn of Jurgen Windcaller"
1 个解决方案
#1
3
Assuming you want the entire line if it starts with a capital letter, you can simplify your regex and just match a capital letter at the beginning of the string:
假设您想要整个行,如果它以大写字母开头,您可以简化regex,在字符串的开头匹配一个大写字母:
^[A-Z].*
regex101演示
#1
3
Assuming you want the entire line if it starts with a capital letter, you can simplify your regex and just match a capital letter at the beginning of the string:
假设您想要整个行,如果它以大写字母开头,您可以简化regex,在字符串的开头匹配一个大写字母:
^[A-Z].*
regex101演示