正则表达式语法 javafx
一个愚蠢的问题,我不确定以下 javafx 正则表达式语法有什么问题。 Netbeans 抱怨整个正则表达式字符串中存在非法转义字符,
var pattern:String = "(\/S*)(ftp|http|https):\/\/(\w+:\{0,1\}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?";
非常感谢任何帮助。非常感谢。
干杯, 阿比
A silly question, I am not sure what is wrong in the following javafx regex syntax. Netbeans complains illegal escape character in whole of this regex string,
var pattern:String = "(\/S*)(ftp|http|https):\/\/(\w+:\{0,1\}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?";
Any help is greatly appreciated. Thanks a bunch.
Cheers,
Abi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用 double \\ for \
var 模式:String = "(\\/S*)(ftp|http|https):\\/\\/(\\w+:\{0,1\}\\w* @)?(\\S+)(:[0-9]+)?(\\/|\\/([\\w#!:.?+=&%@!\-\\/]) )?”;
Try this double \\ for \
var pattern:String = "(\\/S*)(ftp|http|https):\\/\\/(\\w+:\{0,1\}\\w*@)?(\\S+)(:[0-9]+)?(\\/|\\/([\\w#!:.?+=&%@!\-\\/]))?";
我假设你的问题在这里:
我假设你想说的是可以有或没有“:”。因此,您不需要转义括号,即只需
:{0,1}
,但这只是:?
所以我假设您的意思是:
I assume your problem is here:
I assume what you want to say is there can be a ":" or not. Therefor you don't need to escape the brackets, i.e. only
:{0,1}
, but this is simply:?
So I assume you mean: