我正试图使用以下正则表达式从ios中提取捆绑包id:
^w+(.w+)+
它适用于大多数情况,但在其他情况下失败了。
例如使用以下包装名称:
com.walmartmexico.WalmartMG
com.adobe.Adobe-Reader
com.instacart
gnustos.my.app.com.foo89.app.my.long.package.name.is.very.long
org.freevpn.vpn
com.adobe.scan.ios
com.adobe.Adobe-Reader
fontskeyboard.fonts
co.9count.wink
biser.stories
com.ephedra-software.StackOv
de.barbaraherold.freiheit
它没有完全捕捉到那些炒作的东西:
com.ephedra-software.StackOv
com.adobe.Adobe-Reader
有什么想法吗?我如何更改上面的正则表达式以包括上面的内容。
我会使用:
^w+(?:[.-]w+)*$
演示
说明:
^ from the start of the input
w+ match one or more word characters
(?: followed by
[.-] dot or hyphen separator
w+ one or more word characters
)* subsequent terms zero or more times
$ end of the input